小编Dar*_*l42的帖子

WPF DataGrid RowDetails可见性绑定到属性(仅限XAML)

我有一个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中实现类似的功能,但不幸的是我没有丝毫的线索.有任何想法吗?建议?

c# data-binding wpf xaml datagrid

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

data-binding ×1

datagrid ×1

wpf ×1

xaml ×1