Back to Devexpress

TableView.IsDetailButtonVisibleBinding Property

wpf-devexpress-dot-xpf-dot-grid-dot-tableview-e1935d41.md

latest5.8 KB
Original Source

TableView.IsDetailButtonVisibleBinding Property

Gets or sets the binding that determines which rows display detail expand buttons.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
[DefaultValue(null)]
public BindingBase IsDetailButtonVisibleBinding { get; set; }
vb
<DefaultValue(Nothing)>
Public Property IsDetailButtonVisibleBinding As BindingBase

Property Value

TypeDefaultDescription
BindingBasenull

A BindingBase object specifying which rows display detail expand buttons.

|

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.

View Example: Specify Detail Buttons Visibility

xaml
<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>
cs
[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;
    }
}
vb
<ValueConversion(GetType(Object), GetType(Boolean))>
Public Class MyConverter
    Implements IValueConverter

    Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
        ' Obtain the value to be converted:
        Dim categoryValue As String = CStr(value)
        ' Specify values for which to show expand buttons:
        Dim categories As String() = New String() {"First", "Third"}
        If categories.Contains(categoryValue) Then Return True
        ' Disable expand buttons if the value is not in the list:
        Return False
    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
        Return Nothing
    End Function
End Class

See Also

ExpandMasterRow(Int32, DetailDescriptorBase)

CollapseMasterRow(Int32, DetailDescriptorBase)

MasterRowExpanding

MasterRowCollapsing

ShowDetailButtons

TableView Class

TableView Members

DevExpress.Xpf.Grid Namespace