TableView.IsDetailButtonVisibleBinding Property
Gets or sets the binding that determines which rows display detail expand buttons.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.dll
NuGet Package: DevExpress.Wpf.Grid.Core
#Declaration
[DefaultValue(null)]
public BindingBase IsDetailButtonVisibleBinding { get; set; }
#Property Value
Type | Default | Description |
---|---|---|
Binding |
null | A Binding |
#Remarks
The IsDetailButtonVisibleBinding
property allows you to selectively hide detail expand buttons. The default DataContext
for this binding is the master row. You can specify a converter that returns whether to display details buttons based on master row data.
You and your users can expand master rows even if expand buttons are hidden. To expand a master row, you can use the Ctrl
++
shortcut or the ExpandMasterRow method. If you want to disable the Master-Detail functionality, use the TableView.AllowMasterDetail option instead.
#Example
This example uses the TableView.IsDetailButtonVisibleBinding
property to conditionally hide detail expand buttons. The master row value is passed to the converter that returns true
only for specified values.
<Window.Resources>
<local:MyConverter x:Key="myConverter"/>
</Window.Resources>
<Grid>
<dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew">
<dxg:GridControl.DetailDescriptor>
<dxg:DataControlDetailDescriptor ItemsSourcePath="Products">
<dxg:DataControlDetailDescriptor.DataControl>
<dxg:GridControl AutoGenerateColumns="AddNew">
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True" ShowGroupPanel="False"/>
</dxg:GridControl.View>
</dxg:GridControl>
</dxg:DataControlDetailDescriptor.DataControl>
</dxg:DataControlDetailDescriptor>
</dxg:GridControl.DetailDescriptor>
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True"
ShowGroupPanel="False"
IsDetailButtonVisibleBinding="{Binding Row.Name, Converter={StaticResource myConverter}}"/>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
[ValueConversion(typeof(object), typeof(bool))]
public class MyConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
// Obtain the value to be converted:
string categoryValue = (string)value;
// Specify values for which to show expand buttons:
string[] categories = new string[] { "First", "Third" };
if (categories.Contains(categoryValue))
return true;
// Disable expand buttons if the value is not in the list:
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return null;
}
}