Display all the columns header of a radgridview in a listbox of raddropdownbutton to allow users to choose which columns to display

0 Answers 22 Views
Buttons ListBox
Lim
Top achievements
Rank 1
Iron
Lim asked on 26 Feb 2025, 08:08 AM

Hi,

As mentioned above, I would like to add a button that allows me to select which columns of the radgridview that I want to show. May I seek your advise on this?

Lim
Top achievements
Rank 1
Iron
commented on 26 Feb 2025, 08:30 AM

I tried the following but it doesn't work.

 

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.ColumnsDefinitions>
            <ColumnsDefinition Height="Auto" />
            <ColumnsDefinition Height="50" />
            <ColumnsDefinition />
        </Grid.ColumnsDefinitions>
<telerik:RadDropDownButton AutoOpenDelay="0:0:0.0" 
                           Content="Choose an Item"> 
    <telerik:RadDropDownButton.DropDownContent> 
        <ListBox ItemsSource="{Binding Columns, ElementName=RadGridView1}" Grid.Column="0">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <CheckBox Content="{Binding Header}" IsChecked="{Binding IsVisible, Mode=TwoWay}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </telerik:RadDropDownButton.DropDownContent> 
</telerik:RadDropDownButton> 
        <telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding View}" Grid.Column="1" />
    </Grid>
</Window>
Stenly
Telerik team
commented on 26 Feb 2025, 08:37 AM

Hello Lim,

I tested the above code snippet and it works correctly on my end. I attached a sample project that showcases this for you to test.

Would it be possible to give it a try and see if I am missing something of importance?  

Lim
Top achievements
Rank 1
Iron
commented on 26 Feb 2025, 08:49 AM

Hi, I ran your project but nothing was shown on the mainwindow. Did I miss out something?
Stenly
Telerik team
commented on 26 Feb 2025, 09:00 AM

This could be the case when using the NoXaml version of our assemblies without merging the resource dictionaries for the applied theme.

The following article showcases the most common cases of missing controls in the UI:

Missing Controls in the UI - Telerik UI for WPF

Lim
Top achievements
Rank 1
Iron
commented on 26 Feb 2025, 09:28 AM

I see! Thanks!

No answers yet. Maybe you can help?

Tags
Buttons ListBox
Asked by
Lim
Top achievements
Rank 1
Iron
Share this question
or