0
我有名單,在我的數據類項目奇怪的問題:Silverlight。與結合
public ObservableCollection<Node> NodesFromDatabase
{
get
{
if (_nodesFromDatabase == null)
_nodesFromDatabase =GenerateMenuNodes();
return _nodesFromDatabase ;
}
set
{
_nodesFromDatabase = value;
}
}
而且在控制財產,我想結合這個數據:
public ObservableCollection<Node> Nodes
{
get { return (ObservableCollection<Node>)GetValue(NodesProperty); }
set
{
SetValue(NodesProperty, value);
}
}
private static DependencyProperty NodesProperty =
DependencyProperty.Register(
"Nodes",
typeof(ObservableCollection<Node>),
typeof(Control),new PropertyMetadata(new ObservableCollection<Node>()));
在XAML中,我有這樣的代碼:
<Grid Background="White">
<Grid.DataContext>
<local:DataFromDataBase x:Name="database" />
</Grid.DataContext>
<local:Control Nodes="{Binding NodesFromDatabase}" />
</Grid>
而我在這段代碼背後有奇怪的邏輯。
My NodesFromDatabase屬性在get語句中觸發,但控制節點設置語句不會觸發!我在做什麼錯了?