This question is locked. New answers and comments are not allowed.
Hello,
i have a grid with a dynamic header. Works fine but when i choose your solution for a column chooser then the application crashes. Is their any work around possible here? If you wish i can send the complete soure code i have a the source for a test project ready for you.
kind regards,
Jonam
Columchooser
Application:
i have a grid with a dynamic header. Works fine but when i choose your solution for a column chooser then the application crashes. Is their any work around possible here? If you wish i can send the complete soure code i have a the source for a test project ready for you.
kind regards,
Jonam
Columchooser
<controls:ChildWindow x:Class="ColumnSelectorBudget.ColumnChooser" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" Width="400" Height="300" Title="ColumnChooser"> <Grid x:Name="LayoutRoot" Margin="2"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition /> <RowDefinition Height="55"/> </Grid.RowDefinitions> <TextBlock x:Name="textBlockAvailableColumns" Text="Beschikbare velden:" /> <ListBox ItemsSource="{Binding Kolommen}" Grid.Row="1"> <ListBox.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding Header}" IsChecked="{Binding IsVisible, Mode=TwoWay}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <Button x:Name="OnButton" Grid.Row="2" Content="Alles aan" Width="75" HorizontalAlignment="Left" VerticalAlignment="Center" Click="OnButton_Click" /> <Button x:Name="OffButton" Grid.Row="2" Margin="80,0,0,0" Content="Alles uit" HorizontalAlignment="Left" VerticalAlignment="Center" Click="OffButton_Click" /> <Button x:Name="CancelButton" Grid.Row="2" Content="Sluit" Width="75" HorizontalAlignment="Right" Click="CancelButton_Click" VerticalAlignment="Center" /> </Grid></controls:ChildWindow>using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using Telerik.Windows.Controls;namespace ColumnSelectorBudget{ public partial class ColumnChooser : ChildWindow { private readonly RadGridView _currentGrid; public ColumnChooser(RadGridView grid) { InitializeComponent(); _currentGrid = grid; //this.DataContext = grid; DataContext = this; } public GridViewColumnCollection Kolommen { get { return _currentGrid.Columns; } } private void CancelButton_Click(object sender, RoutedEventArgs e) { this.DialogResult = false; } private void OnButton_Click(object sender, RoutedEventArgs e) { foreach (var item in _currentGrid.Columns) item.IsVisible = true; } private void OffButton_Click(object sender, RoutedEventArgs e) { foreach (var item in _currentGrid.Columns) item.IsVisible = false; } }}Application:
<telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Label1}"> <telerik:GridViewDataColumn.Header> <TextBlock Text="{Binding Label1,Source={StaticResource Headers}}" /> </telerik:GridViewDataColumn.Header> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> xmlns:helpers="clr-namespace:ColumnSelectorBudget" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <UserControl.Resources> <helpers:LabelHeaders x:Key="Headers" /> </UserControl.Resources> public class LabelHeaders { public string Label1 { get { // normally a dynamic property return "Label1"; } } }