This is a migrated thread and some comments may be shown as answers.

Reusable ControlPanelItems?

2 Answers 164 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vitor
Top achievements
Rank 1
Vitor asked on 16 Mar 2016, 01:29 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 21 Mar 2016, 08:01 AM
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.
0
Vitor
Top achievements
Rank 1
answered on 21 Mar 2016, 01:24 PM

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

Tags
GridView
Asked by
Vitor
Top achievements
Rank 1
Answers by
Martin
Telerik team
Vitor
Top achievements
Rank 1
Share this question
or