Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions VB/WPFGrid_ColumnChooser.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32421.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WPFGrid_ColumnChooser", "WPFGrid_ColumnChooser\WPFGrid_ColumnChooser.vbproj", "{3070DF24-C291-4248-BDBA-E235F21D9626}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3070DF24-C291-4248-BDBA-E235F21D9626}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3070DF24-C291-4248-BDBA-E235F21D9626}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3070DF24-C291-4248-BDBA-E235F21D9626}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3070DF24-C291-4248-BDBA-E235F21D9626}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {745E24C6-3160-40E9-9C9B-7E4C4285A710}
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions VB/WPFGrid_ColumnChooser/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="WPFGrid_ColumnChooser.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFGrid_ColumnChooser"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
10 changes: 10 additions & 0 deletions VB/WPFGrid_ColumnChooser/App.xaml.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Namespace WPFGrid_ColumnChooser

''' <summary>
''' Interaction logic for App.xaml
''' </summary>
Public Partial Class App
Inherits Application

End Class
End Namespace
6 changes: 6 additions & 0 deletions VB/WPFGrid_ColumnChooser/AssemblyInfo.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'(used if a resource is not found in the page,
' or application resource dictionaries)
'(used if a resource is not found in the page,
' app, or any theme specific resource dictionaries)
<Assembly:ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)> 'where theme specific resource dictionaries are located
'where the generic resource dictionary is located
27 changes: 27 additions & 0 deletions VB/WPFGrid_ColumnChooser/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Window x:Class="WPFGrid_ColumnChooser.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFGrid_ColumnChooser"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
mc:Ignorable="d"
Title="MainWindow" Height="300" Width="500">
<Window.Resources>
<DataTemplate x:Key="columnChooserTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}"/>
<Button Content="Click" Margin="5,0,0,0"/>
</StackPanel>
</DataTemplate>

<local:HeaderTemplateSelector x:Key="headerTemplateSelector"
ColumnChooserTemplate="{StaticResource columnChooserTemplate}"/>
</Window.Resources>

<dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew">
<dxg:GridControl.View>
<dxg:TableView x:Name="view" ColumnHeaderTemplateSelector="{StaticResource headerTemplateSelector}"/>
</dxg:GridControl.View>
</dxg:GridControl>
</Window>
38 changes: 38 additions & 0 deletions VB/WPFGrid_ColumnChooser/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Imports DevExpress.Xpf.Grid
Imports System.Windows.Controls

Namespace WPFGrid_ColumnChooser

Public Partial Class MainWindow
Inherits Window

Public Sub New()
InitializeComponent()
Dim items As ObservableCollection(Of Item) = New ObservableCollection(Of Item)()
For i As Integer = 1 To 30 - 1
items.Add(New Item() With {.Id = i, .Name = "Name" & i})
Next

grid.ItemsSource = items
view.ShowColumnChooser()
End Sub
End Class

Public Class HeaderTemplateSelector
Inherits DataTemplateSelector

Public Property ColumnChooserTemplate As DataTemplate

Public Overrides Function SelectTemplate(ByVal item As Object, ByVal container As DependencyObject) As DataTemplate
If ColumnBase.GetHeaderPresenterType(container) = HeaderPresenterType.ColumnChooser AndAlso Equals(CStr(item), NameOf(WPFGrid_ColumnChooser.Item.Id)) Then Return ColumnChooserTemplate
Return MyBase.SelectTemplate(item, container)
End Function
End Class

Public Class Item

Public Property Id As Integer

Public Property Name As String
End Class
End Namespace
16 changes: 16 additions & 0 deletions VB/WPFGrid_ColumnChooser/WPFGrid_ColumnChooser.vbproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OptionInfer>On</OptionInfer>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<EnableDefaultApplicationDefinition>false</EnableDefaultApplicationDefinition>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Wpf" Version="21.2.8" />
</ItemGroup>
</Project>