Reusable ControlPanelItems?

3 posts, 1 answers
  1. Vitor
    Vitor avatar
    53 posts
    Member since:
    Mar 2016

    Posted 16 Mar Link to this post

    Hello Telerik,

     

    I wanted to implement a column chooser for a grid. Then I followed this doc here

    http://docs.telerik.com/devtools/wpf/controls/radgridview/features/overview-controlpanel

    and found out that I basically just need to add this piece of code inside my grid to achieve the desired feature.

    <telerik:RadGridView.ControlPanelItems>
        <telerik:ControlPanelItem ButtonTooltip="Column chooser">
            <telerik:ControlPanelItem.Content>
                <ListBox ItemsSource="{Binding Columns}" BorderThickness="0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <CheckBox Content="{Binding Header, Mode=OneWay}" IsChecked="{Binding IsVisible, Mode=TwoWay}" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </telerik:ControlPanelItem.Content>
        </telerik:ControlPanelItem>
    </telerik:RadGridView.ControlPanelItems>

     

     

     
    Now my question is:
    Is there a way I can reuse this block of code in several grids? Such as via usercontrols?

    I just want to keep my code clean.
    please show me the way.
    Thank you!

  2. Answer
    Martin Vatev
    Admin
    Martin Vatev avatar
    87 posts

    Posted 21 Mar Link to this post

    Hello Vitor,

     In order to reach the desired behavior, you may choose between two approaches. The first one is to Implicitly Set the Control Panel Items which is our recommended approach. The second one
    is to Explicitly Set the Control Panel Items. Both approaches allow the code to be defined only in one place and many grids to reuse it.

    I hope that this helps. Should you have any other questions, do not hesitate to contact us.


    Regards,
    Martin Vatev
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vitor
    Vitor avatar
    53 posts
    Member since:
    Mar 2016

    Posted 21 Mar in reply to Martin Vatev Link to this post

    Thank you! That is exactly what I was looking for!!!

Back to Top