2012-05-21 61 views
0

我在窗口中有一個類的入口。在window.Resources我創建:刷新代碼中的資源對象

<local:ColorType x:Key="myClrData" /> 

在入門,我有11個文本框/的TextBlocks和所有綁定到myClrData的proerties:

<TextBox Name="dfTxt" MinWidth="50" Grid.Column="1" Grid.Row="1" Style="{StaticResource numberTextStyle}" 
     Text="{Binding Source={StaticResource myClrData}, Path=D_F}" /> 
<TextBlock Name="dfPerc" Grid.Column="2" Grid.Row="1" Style="{StaticResource numberTBStyle}" 
      Text="{Binding Source={StaticResource myClrData}, Path=D_F_Percent}" /> 

這工作得很好,當我要添加一個新的條目。我關心的是我想更新對象的細節。爲此,我在窗口類中添加了:

public ColorTorWindow(ColorType ct) 
    : this() 
{ 
    this.Resources["myClrData"] = ct; 

} 

但是,這不會刷新綁定到它的文本框/塊。這裏缺少什麼?我該如何強制重新刷新所有組件,或者是否應該以其他方式進行工作。

任何幫助,高度讚賞。

謝謝

回答

0

我正在使用Datacontext,它解決了我的問題。

謝謝