我有一个DataGrid显示一堆对象.这些对象有一个属性IsDetailsExpanded,我想将DataRows DetailsVisibility属性绑定到该属性.
我的第一种方法有效,但需要一些代码隐藏(我想摆脱它)
我处理这个LoadingRow事件
void LoadingRowHandler(object sender, DataGridRowEventArgs e)
{
Binding b = new Binding()
{
Source = e.Row.DataContext,
Path = new PropertyPath("IsExpanded"),
Converter = (IValueConverter)Resources["BoolToVisi"],
Mode = BindingMode.TwoWay
};
e.Row.SetBinding(DataGridRow.DetailsVisibilityProperty, b);
}
Run Code Online (Sandbox Code Playgroud)
我认为必须有一种方法可以在XAML中实现类似的功能,但不幸的是我没有丝毫的线索.有任何想法吗?建议?