I noticed an interesting bug in WPF, and I wondered if anyone else had seen it, and if so, how did they get around this?
I have a Window , and inside there is a GroupBox inside which there is a TextBox . DataContext on the GroupBox set to an object inside my program, and as a result, the binding to the TextBox set as follows:
<TextBox Text="{Binding Directory_Data}" IsReadOnly="True" Name="dataPath_TextBox" Grid.Column="0" Grid.Row="1" Height="23" Margin="6,3,3,3"/>
On Windows 7 (which I am developing) this works fine, and I had no reason to even think twice about this XAML line. However, during some tests in Windows XP (with .NET4.0 installed), opening this Window caused the entire program to crash with this error:
EventType: clr20r3, system.invalidoperationexception.
It took me a long time to work with the code until I finally narrowed it down to the XAML line.
Changing the TextBox to Label (and changing the Text property to Content ) prevented this failure, and the program worked as planned; this is just a TextBox error.
Although you can simply switch the TextBox to the Label (given that in my case it will be ReadOnly ), I would prefer a TextBox for the look. Maybe I need to update the Text property manually from the code below.
In any case, basically, I just wanted to point out this problem if someone else encounters something like this. Any thoughts on why this, however, would be appreciated.