Catastrophic failure on PropertyChanged
-
Saturday, October 13, 2012 1:31 AM
In my Page there is a tabControl with 2 tabItem
and per tabItem contains one textBox yhat binds to Title And Title1 of my SampleData class
SampleData class Impelement InotifyPropertyChanged
I have a button that in button click i change title And title1 of SampleData
this is my code:
<Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="30"></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Button Click="Button_Click" >Test</Button> <sdk:TabControl Grid.Row="1"> <sdk:TabItem Header="Title Tab"> <TextBox Width="120" Height="30" Text="{Binding Title}"></TextBox> </sdk:TabItem> <sdk:TabItem Header="Title2 Tab"> <TextBox Width="120" Height="30" Text="{Binding Title2}"></TextBox> </sdk:TabItem> </sdk:TabControl> </Grid>
public class SampleData:INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public int Id { get; set; } private string _title; public string Title { get { return _title; } set { _title = value; NotifyPropertyChanged("Title"); } } private void NotifyPropertyChanged(string propName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propName)); } private string _title2; public string Title2 { get { return _title2; } set { _title2 = value; NotifyPropertyChanged("Title2"); } } }
public partial class MainPage : UserControl { private SampleData s; public MainPage() { InitializeComponent(); s = new SampleData {Id=1,Title = "Title1",Title2 = "Title2"}; LayoutRoot.DataContext = s; } private void Button_Click(object sender, RoutedEventArgs e) { s.Title += "1"; s.Title2 += "2"; } }when selectedTabItem is tab2 silverlight exceprtion raise on
s.Title += "1";
the exception is
{System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, String s)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
at System.Windows.Data.BindingExpression.SourcePropertyChanged(PropertyPathListener sender, PropertyPathChangedEventArgs args)
at System.Windows.PropertyPathListener.ReconnectPath()
at System.Windows.Data.Debugging.BindingBreakPoint.<>c__DisplayClass4.<BreakOnSharedType>b__3()}
my page flowdirection is RightToLeft
when i change flowdirection to lefttoright exception not happenmy sampe code

