Visual Studio Development Bookmark and Share   
 index > Visual Studio WPF Designer > WPF designer crashes on very simple data binding example
 

WPF designer crashes on very simple data binding example

I'm trying to learn data binding but C# crashes on this very simple example. This crash happens everytime I try to set the property PersonName the Person object.
<Window x:Class="BindingTest.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:src="clr-namespace:BindingTest"
  Title="Simple Data Binding Sample">
    <Window.Resources>
        <src:Person x:Key="myDataSource" PersonName=""/>
    </Window.Resources>
</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace BindingTest
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
    }

    public class Person : INotifyPropertyChanged
    {
        String internal_PersonName;

        public Person()
        {
        }
        
        public String PersonName
        {
            get
            {
                return internal_PersonName;
            }
            set
            {
                PersonName = value;
                
                if (PropertyChanged != null)                
                    PropertyChanged(this, new PropertyChangedEventArgs("PersonName"));
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}

It literally crashes a second or two after typing "PersonName=". Every time.

Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1

Installed Edition: C# Express

Microsoft Visual C# 2008 91910-152-0000061-60471
Microsoft Visual C# 2008

Hotfix for Microsoft Visual C# 2008 Express Edition with SP1 - ENU (KB945282) KB945282
This hotfix is for Microsoft Visual C# 2008 Express Edition with SP1 - ENU.
If you later install a more recent service pack, this hotfix will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/945282.

Hotfix for Microsoft Visual C# 2008 Express Edition with SP1 - ENU (KB946040) KB946040
This hotfix is for Microsoft Visual C# 2008 Express Edition with SP1 - ENU.
If you later install a more recent service pack, this hotfix will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946040.

Hotfix for Microsoft Visual C# 2008 Express Edition with SP1 - ENU (KB946308) KB946308
This hotfix is for Microsoft Visual C# 2008 Express Edition with SP1 - ENU.
If you later install a more recent service pack, this hotfix will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946308.

Hotfix for Microsoft Visual C# 2008 Express Edition with SP1 - ENU (KB947540) KB947540
This hotfix is for Microsoft Visual C# 2008 Express Edition with SP1 - ENU.
If you later install a more recent service pack, this hotfix will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947540.

Hotfix for Microsoft Visual C# 2008 Express Edition with SP1 - ENU (KB947789) KB947789
This hotfix is for Microsoft Visual C# 2008 Express Edition with SP1 - ENU.
If you later install a more recent service pack, this hotfix will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947789.

Hotfix for Microsoft Visual C# 2008 Express Edition with SP1 - ENU (KB958017) KB958017
This hotfix is for Microsoft Visual C# 2008 Express Edition with SP1 - ENU.
If you later install a more recent service pack, this hotfix will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/958017.

OS Name Microsoft Windows XP Home Edition
Version 5.1.2600 Service Pack 3 Build 2600

I just uninstalled .NET 3.5 SP1 and reinstalled it. No effect.

Any help would be greatly appreciated
chriswatrous  Sunday, August 30, 2009 7:54 AM
Oops. Dumb mistake on my part. For the property PersonName set I should have had internal_PersonName = value; instead of PersonName = value; . That seems to have fixed the problem. Still, it would be nice if Visual Studio didn't crash when I do something dumb like that. Oh well.
chriswatrous  Sunday, August 30, 2009 8:05 AM
That is expected as you have an infinite loop.
JRQ  Friday, September 25, 2009 8:48 PM

You can use google to search for other answers

Custom Search

More Threads

• Store WPF windows in dll file
• User Control placement resizing bug
• Control.FontSize and custom FontSize with Button
• textbox.text to Numeric
• Getting a list of the WPF controls in the Toolbox
• How can i see preview of window form
• How do I see the WPF Designer?
• Control Toolbox - WinForms and WPF Controls.
• Problem: Xbap won't design xaml in subfolders; IDE goes "Whoops"
• Using PageContent element in a FixedDocument object