Skip to content

Commit c46693a

Browse files
committed
Add MultiSelectionComboBox-Demo
1 parent afd6617 commit c46693a

3 files changed

Lines changed: 161 additions & 31 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<UserControl x:Class="MetroDemo.ExampleViews.MultiSelectionComboBoxExample"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:local="clr-namespace:MetroDemo"
6+
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:system="clr-namespace:System;assembly=mscorlib"
9+
d:DataContext="{d:DesignInstance local:MainWindowViewModel}"
10+
d:DesignHeight="450"
11+
d:DesignWidth="800"
12+
mc:Ignorable="d">
13+
<UserControl.Resources>
14+
<Style BasedOn="{StaticResource MahApps.Styles.MetroHeader.Horizontal}" TargetType="mah:MetroHeader" />
15+
<Style TargetType="GroupBox" BasedOn="{StaticResource MahApps.Styles.GroupBox}">
16+
<Setter Property="Margin" Value="5,5,5,0" />
17+
</Style>
18+
19+
<ObjectDataProvider x:Key="Demo.Enums.OrderSelectedItemsBy" MethodName="GetValues" ObjectType="{x:Type system:Enum}">
20+
<ObjectDataProvider.MethodParameters>
21+
<x:Type TypeName="mah:OrderSelectedItemsBy" />
22+
</ObjectDataProvider.MethodParameters>
23+
</ObjectDataProvider>
24+
25+
<ObjectDataProvider x:Key="Demo.Enums.SelectionMode" MethodName="GetValues" ObjectType="{x:Type system:Enum}">
26+
<ObjectDataProvider.MethodParameters>
27+
<x:Type TypeName="SelectionMode" />
28+
</ObjectDataProvider.MethodParameters>
29+
</ObjectDataProvider>
30+
31+
</UserControl.Resources>
32+
<Grid>
33+
<Grid.ColumnDefinitions>
34+
<ColumnDefinition Width="*" MinWidth="250" />
35+
<ColumnDefinition Width="Auto" />
36+
<ColumnDefinition Width="*" MinWidth="50"/>
37+
</Grid.ColumnDefinitions>
38+
39+
<ScrollViewer Grid.Column="0" Grid.IsSharedSizeScope="True" VerticalScrollBarVisibility="Auto">
40+
<StackPanel>
41+
<GroupBox Header="Text">
42+
<StackPanel>
43+
<mah:MetroHeader Header="Text">
44+
<TextBox Text="{Binding ElementName=mscb_Example, Path=Text}" />
45+
</mah:MetroHeader>
46+
<mah:MetroHeader Header="IsEditable">
47+
<mah:ToggleSwitch IsOn="{Binding ElementName=mscb_Example, Path=IsEditable}" />
48+
</mah:MetroHeader>
49+
<mah:MetroHeader Header="IsReadOnly">
50+
<mah:ToggleSwitch IsOn="{Binding ElementName=mscb_Example, Path=IsReadOnly}" />
51+
</mah:MetroHeader>
52+
</StackPanel>
53+
</GroupBox>
54+
55+
<GroupBox Header="MahApps Helper">
56+
<StackPanel>
57+
<mah:MetroHeader Header="Watermark">
58+
<TextBox Text="{Binding ElementName=mscb_Example, Path=(mah:TextBoxHelper.Watermark)}" />
59+
</mah:MetroHeader>
60+
<mah:MetroHeader Header="UseFloatingWatermark">
61+
<mah:ToggleSwitch IsOn="{Binding ElementName=mscb_Example, Path=(mah:TextBoxHelper.UseFloatingWatermark)}" />
62+
</mah:MetroHeader>
63+
<mah:MetroHeader Header="AutoWatermark">
64+
<mah:ToggleSwitch IsOn="{Binding ElementName=mscb_Example, Path=(mah:TextBoxHelper.AutoWatermark)}" />
65+
</mah:MetroHeader>
66+
<mah:MetroHeader Header="ClearTextButton">
67+
<mah:ToggleSwitch IsOn="{Binding ElementName=mscb_Example, Path=(mah:TextBoxHelper.ClearTextButton)}" />
68+
</mah:MetroHeader>
69+
</StackPanel>
70+
</GroupBox>
71+
72+
<GroupBox Header="Selection">
73+
<StackPanel>
74+
<mah:MetroHeader Header="SelectionMode">
75+
<ComboBox SelectedItem="{Binding ElementName=mscb_Example, Path=SelectionMode}" ItemsSource="{Binding Source={StaticResource Demo.Enums.SelectionMode}}"/>
76+
</mah:MetroHeader>
77+
<mah:MetroHeader Header="OrderSelectedItemsBy">
78+
<ComboBox SelectedItem="{Binding ElementName=mscb_Example, Path=OrderSelectedItemsBy}" ItemsSource="{Binding Source={StaticResource Demo.Enums.OrderSelectedItemsBy}}"/>
79+
</mah:MetroHeader>
80+
</StackPanel>
81+
</GroupBox>
82+
</StackPanel>
83+
</ScrollViewer>
84+
85+
<GridSplitter Grid.Column="1"
86+
Width="3"
87+
VerticalAlignment="Stretch" />
88+
89+
<GroupBox Grid.Column="2" Header="Result">
90+
<Grid>
91+
<mah:MultiSelectionComboBox x:Name="mscb_Example"
92+
Margin="5"
93+
VerticalAlignment="Center"
94+
SelectedItemsTemplate="{DynamicResource MahApps.DataTemplates.MultiSelectionComboBox.Removeable}"
95+
DisplayMemberPath="Genre"
96+
ItemsSource="{Binding Albums}" />
97+
</Grid>
98+
</GroupBox>
99+
</Grid>
100+
</UserControl>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace MetroDemo.ExampleViews
17+
{
18+
/// <summary>
19+
/// Interaction logic for MultiSelectionComboBoxExample.xaml
20+
/// </summary>
21+
public partial class MultiSelectionComboBoxExample : UserControl
22+
{
23+
public MultiSelectionComboBoxExample()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@
7878
<Setter Property="Header" Value="{Binding Mode=OneTime}" />
7979
</Style>
8080

81-
<UserControl x:Key="CustomDialogTest"
82-
x:Name="CustomDialogTest"
81+
<UserControl x:Key="CustomDialogTest" x:Name="CustomDialogTest"
8382
MinHeight="200">
8483

8584
<TextBlock x:Name="MessageTextBlock" Text="Message shown by this custom Dialog." />
@@ -89,12 +88,12 @@
8988
<UserControl x:Key="CustomCloseDialogTest" x:Name="CustomCloseDialogTest">
9089

9190
<StackPanel>
92-
<TextBlock Height="30"
93-
Margin="0 4"
94-
Text="This dialog allows arbitrary content. You have to close it yourself by clicking the close button below."
91+
<TextBlock Text="This dialog allows arbitrary content. You have to close it yourself by clicking the close button below."
92+
Height="30"
93+
Margin="0,4"
9594
TextWrapping="Wrap" />
96-
<Button Click="CloseCustomDialog"
97-
Content="Close Me!"
95+
<Button Content="Close Me!"
96+
Click="CloseCustomDialog"
9897
Style="{DynamicResource MahApps.Styles.Button.Dialogs}" />
9998
</StackPanel>
10099

@@ -115,23 +114,23 @@
115114

116115
<mah:MetroWindow.RightWindowCommands>
117116
<mah:WindowCommands ShowLastSeparator="False">
118-
<Button Click="LaunchFlyoutDemo"
119-
Content="Flyouts"
117+
<Button Content="Flyouts"
118+
Click="LaunchFlyoutDemo"
120119
ToolTip="Flyouts demo window" />
121-
<Button Click="LaunchIcons"
122-
Content="IconPacks"
120+
<Button Content="IconPacks"
121+
Click="LaunchIcons"
123122
ToolTip="All MahApp icons" />
124-
<Button Click="LaunchVisualStudioDemo"
125-
Content="VS"
123+
<Button Content="VS"
124+
Click="LaunchVisualStudioDemo"
126125
ToolTip="Visual Studio style demo" />
127-
<Button Click="LauchCleanDemo"
128-
Content="Clean"
126+
<Button Content="Clean"
127+
Click="LauchCleanDemo"
129128
ToolTip="Clean window style demo" />
130-
<Button Click="InteropDemo"
131-
Content="Interop"
129+
<Button Content="Interop"
130+
Click="InteropDemo"
132131
ToolTip="The interop demo" />
133-
<Button Click="LaunchNavigationDemo"
134-
Content="Navigation"
132+
<Button Content="Navigation"
133+
Click="LaunchNavigationDemo"
135134
ToolTip="Window navigation demo" />
136135
<ToggleButton Content="Confirm quit"
137136
IsChecked="{Binding QuitConfirmationEnabled}"
@@ -194,12 +193,12 @@
194193
<MenuItem Command="{Binding ShowInputDialogCommand}" Header="Show InputDialog via VM" />
195194
<MenuItem Command="{Binding ShowLoginDialogCommand}" Header="Show LoginDialog via VM ..." />
196195
<MenuItem Header="Show MessageDialog via VM">
197-
<MenuItem Command="{Binding ShowMessageDialogCommand}"
198-
CommandParameter="DISPATCHER_THREAD"
199-
Header="... from Main Thread" />
200-
<MenuItem Command="{Binding ShowMessageDialogCommand}"
201-
CommandParameter="BACKGROUND_THREAD"
202-
Header="... from Background Thread" />
196+
<MenuItem Header="... from Main Thread"
197+
Command="{Binding ShowMessageDialogCommand}"
198+
CommandParameter="DISPATCHER_THREAD" />
199+
<MenuItem Header="... from Background Thread"
200+
Command="{Binding ShowMessageDialogCommand}"
201+
CommandParameter="BACKGROUND_THREAD" />
203202
</MenuItem>
204203

205204
<MenuItem Command="{Binding ShowProgressDialogCommand}" Header="Show ProgressDialog via VM" />
@@ -228,23 +227,22 @@
228227
<MenuItem Click="MenuWindowWithShadowOnClick" Header="Window with drop shadow" />
229228
<MenuItem Click="LaunchSizeToContentDemo" Header="Window with SizeToContent" />
230229
<Separator />
231-
<MenuItem x:Name="ShowSeparatorsMI"
232-
Header="ShowSeparators (RightWindowCommands)"
230+
<MenuItem x:Name="ShowSeparatorsMI" Header="ShowSeparators (RightWindowCommands)"
233231
IsCheckable="True"
234232
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=RightWindowCommands.ShowSeparators}" />
235233
<MenuItem Header="ShowLastSeparator in (RightWindowCommands)"
236234
IsCheckable="True"
237235
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=RightWindowCommands.ShowLastSeparator}"
238236
IsEnabled="{Binding ElementName=ShowSeparatorsMI, Path=IsChecked, Mode=OneWay}" />
239237
<Separator />
240-
<MenuItem Command="{Binding ToggleIconScalingCommand}"
238+
<MenuItem Header="Window icon: scale down larger frame"
239+
Command="{Binding ToggleIconScalingCommand}"
241240
CommandParameter="{x:Static mah:MultiFrameImageMode.ScaleDownLargerFrame}"
242-
Header="Window icon: scale down larger frame"
243241
IsCheckable="True"
244242
IsChecked="{Binding IsScaleDownLargerFrame, Mode=OneWay}" />
245-
<MenuItem Command="{Binding ToggleIconScalingCommand}"
243+
<MenuItem Header="Window icon: no scale, smaller frame"
244+
Command="{Binding ToggleIconScalingCommand}"
246245
CommandParameter="{x:Static mah:MultiFrameImageMode.NoScaleSmallerFrame}"
247-
Header="Window icon: no scale, smaller frame"
248246
IsCheckable="True"
249247
IsChecked="{Binding IsNoScaleSmallerFrame, Mode=OneWay}" />
250248
<Separator />
@@ -334,6 +332,10 @@
334332
<exampleViews:ColorPickerExample />
335333
</TabItem>
336334

335+
<TabItem Header="MultiSelectionComboBox">
336+
<exampleViews:MultiSelectionComboBoxExample/>
337+
</TabItem>
338+
337339
<TabItem Header="others">
338340
<ScrollViewer Margin="2"
339341
HorizontalScrollBarVisibility="Auto"

0 commit comments

Comments
 (0)