Toggle Grid columns/headers based on ComboBox CheckBox Items

2 posts, 0 answers
  1. Bobby
    Bobby avatar
    1 posts
    Member since:
    Apr 2014

    Posted 15 Apr 2014 Link to this post

    I have a WPF Grid, a Combo Box and check box fields as items of the combo box. Combobox items are the grid headers/columns. Currently, the ComboBox is binded to the columns of the Grid and Grid header is toggeled based on the toggling of the checkbox items of Combobox.Now, I have to change this behaviour so that only some fileds are visible on the grid and those which are not visible are availabe in the Combobox as non-selected items with the fields that are visible on the grid as selected items. Toggling the checkbox items in the combobox would toggle the grid header/column visibility. Please suggest.

    Grid
    -----
     
    <local:XYZDataGrid x:Name="dataGrid" Visibility="Hidden" ShowGroupPanel="False" HorizontalAlignment="Left" VerticalAlignment="Top" SelectionMode="Extended" FontSize="10" SelectionUnit="Cell" Margin="0,40,0,0" AutoGeneratingColumn="dataGrid_AutoGeneratingColumn" CellEditEnded="dataGrid_CellEditEnded" RowEditEnded="dataGrid_RowEditEnded" PastingCellClipboardContent="dataGrid_PastingCellClipboardContent" Sorting="dataGrid_Sorting" BeginningEdit="dataGrid_BeginningEdit" CellValidating="dataGrid_CellValidating"
                                       ClipboardPasteMode="SkipHiddenColumns, Default, AllSelectedCells, OverwriteWithEmptyValues" Pasting="dataGrid_Pasting" CopyingCellClipboardContent="dataGrid_CopyingCellClipboardContent" PreviewKeyDown="dataGrid_PreviewKeyDown" ValidatesOnDataErrors="InEditMode" ElementExporting="dataGrid_ElementExporting">
                    <telerik:RadGridView.LayoutTransform>
                        <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoom}" ScaleY="{Binding Path=Value, ElementName=zoom}" />
                    </telerik:RadGridView.LayoutTransform>
                    <telerik:RadGridView.SortDescriptors>
                        <telerik:SortDescriptor Member="InformationType" SortDirection="Ascending"/>
                        <telerik:SortDescriptor Member="MaterialInformationID" SortDirection="Ascending"/>
                    </telerik:RadGridView.SortDescriptors>
                </local:XYZDataGrid>

    ComboBox
    ---------
     
    <telerik:RadComboBox EmptyText="Columns" ItemsSource="{Binding Columns, ElementName=dataGrid}" Text="Columns" Margin="750,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="20" SelectionChanged="RadComboBox_SelectionChanged_1">
                    <telerik:RadComboBox.ItemTemplate>                   
                        <DataTemplate>
                            <CheckBox Content="{Binding Header}"
                              IsChecked="{Binding IsVisible, Mode=TwoWay}" />
                        </DataTemplate>
                    </telerik:RadComboBox.ItemTemplate>
                </telerik:RadComboBox>


  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 17 Apr 2014 Link to this post

    Hi Bobby,

    I would suggest that you check the following help topic:
    http://www.telerik.com/help/wpf/radcombobox-howto-enable-disable-radcombobox-items.html -
    it explains how you could enable/disable the items of RadComboBox.

    Hope this will help.

    Regards,
    Yana
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top