我正在将一个 xaml 文件动态加载到我的程序中,该文件具有绑定(bind):
<ListView
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Grid.Row="2" BorderBrush="White" Name="ListView1"
ItemsSource="{Binding Path=line}" HorizontalAlignment="Stretch">
<ListView.View>
<GridView>
<GridViewColumn Header="Lines"
DisplayMemberBinding="{Binding Path=aline}" />
</GridView>
</ListView.View>
</ListView >
在我的程序中,我想检查绑定(bind)是否存在。
这应该如何实现?
编辑:aline
是DataContext
对象的一个属性
最佳答案
您可以像这样检查绑定(bind):
BindingExpression be = BindingOperations.GetBindingExpression(ListView1, ItemsSourceProperty);
return be != null ? "ItemsSource is bound" : "ItemsSource is not bound";
关于c# - 检查数据绑定(bind)是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15116797/