group demo items
This commit is contained in:
1 parent
789eeed609
commit
17d2353107
18 files changed
+256
-162
No files matched your search
@@ -46,7 +46,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:SearchBar ShowClearButton="True" IsRealTime="True" SearchStarted="SearchBar_OnSearchStarted" Style="{StaticResource SearchBarPlus}" hc:InfoElement.Placeholder="{ex:Lang Key={x:Static langs:LangKeys.PlsEnterKey}}" Margin="0,4,4,4" Tag="{Binding ElementName=ListBoxDemo}"/>
|
||||
<ToggleButton Tag="{Binding ElementName=ListBoxDemo}" Name="ButtonStyleAscending" Click="ButtonAscending_OnClick" Grid.Row="0" Grid.Column="1" Style="{StaticResource DemoInfoSortButtonStyle}"/>
|
||||
<ListBox Name="ListBoxDemo" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" SelectedIndex="{Binding SelectedIndex}" ItemsSource="{Binding DemoItemList}" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
|
||||
<ListBox Name="ListBoxDemo" ScrollViewer.CanContentScroll="False" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" SelectedIndex="{Binding SelectedIndex}" ItemsSource="{Binding DemoItemList}" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -56,6 +56,9 @@
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
<ListBox.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource DemoGroupItemStyle}"/>
|
||||
</ListBox.GroupStyle>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
@@ -67,4 +70,4 @@
|
||||
</hc:Interaction.Triggers>
|
||||
</TabControl>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</Border>
|
||||
@@ -1,8 +1,12 @@
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Threading;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.ViewModel;
|
||||
|
||||
@@ -30,7 +34,9 @@ namespace HandyControlDemo.UserControl
|
||||
var selectedIndex = demoInfo.SelectedIndex;
|
||||
demoInfo.SelectedIndex = -1;
|
||||
demoInfo.SelectedIndex = selectedIndex;
|
||||
|
||||
FilterItems();
|
||||
GroupItems(sender as TabControl, demoInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,5 +98,20 @@ namespace HandyControlDemo.UserControl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GroupItems(TabControl tabControl, DemoInfoModel demoInfo)
|
||||
{
|
||||
var listBox = VisualHelper.GetChild<ListBox>(tabControl);
|
||||
if (listBox == null) return;
|
||||
listBox.Items.GroupDescriptions?.Clear();
|
||||
|
||||
if (demoInfo.IsGroupEnabled)
|
||||
{
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
listBox.Items.GroupDescriptions?.Add(new PropertyGroupDescription("GroupName"));
|
||||
}), DispatcherPriority.Background);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user