WPF DataGrid 绑定到 ObservableCollection 没有反应
我创建了一个用户控件。名字为nodesSetCtrl
列表的源,绑定到用户控件本身的NVS4Binding.NodeList
NodeList的类型为ObservableCollection<Node>
<DataGrid Name="dtgNodesInfo"
ItemsSource="{Binding ElementName=nodesSetCtrl,
Path=NVS4Binding.NodeList,
Converter={StaticResource testConverter}}">
</DataGrid>
class TestConverter : IValueConverter
{
public object Convert(object values, Type targetType, object parameter, CultureInfo culture)
{
Debug.WriteLine("Binding is in");
return values;//断点
}
public object ConvertBack(object value, Type targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
<DataGrid.Columns>
<DataGridTextColumn Header="网络号"
Binding="{Binding Path=Net,
Converter={StaticResource testConverter}}"/>
<DataGridTextColumn Header="短地址"
Binding="{Binding Path=Address,
Converter={StaticResource testConverter}}"/>
</DataGrid.Columns>