Skip to content

Commit 9ebc94d

Browse files
committed
minor test
1 parent 1cb363b commit 9ebc94d

File tree

4 files changed

+83
-19
lines changed

4 files changed

+83
-19
lines changed

source/iNKORE.UI.WPF.Modern.Controls/Controls/Windows/CommandBar/AppBarButton.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ private void UpdateVisualState(bool useTransitions = true)
389389
UpdateCommonState(useTransitions);
390390
UpdateKeyboardAcceleratorTextVisibility(useTransitions);
391391
UpdateFlyoutState(useTransitions);
392+
UpdatePrimaryLabelState(useTransitions);
392393
}
393394

394395
private void UpdateCommonState(bool useTransitions = true)
@@ -444,6 +445,12 @@ private void UpdateFlyoutState(bool useTransitions = true)
444445
VisualStateManager.GoToState(this, hasFlyout ? "HasFlyout" : "NoFlyout", useTransitions);
445446
}
446447

448+
private void UpdatePrimaryLabelState(bool useTransitions = true)
449+
{
450+
bool hasPrimaryLabel = /*Flyout != null &&*/ !string.IsNullOrEmpty(Label as string);
451+
VisualStateManager.GoToState(this, hasPrimaryLabel ? "HasPrimaryLabels" : "NoPrimaryLabels", useTransitions);
452+
}
453+
447454
private AppBarElementVisualStateManager _vsm;
448455
}
449456

source/iNKORE.UI.WPF.Modern.Controls/Controls/Windows/CommandBarFlyout/CommandBarFlyout.xaml

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
<Setter Property="VerticalAlignment" Value="Stretch" />
2525
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
2626
<Setter Property="FontWeight" Value="Normal" />
27-
<Setter Property="Width" Value="40" />
28-
<Setter Property="Height" Value="40" />
27+
<Setter Property="Width" Value="NaN" />
2928
<Setter Property="UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
3029
<Setter Property="FocusVisualMargin" Value="0,0,0,2" />
3130
<Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
@@ -46,21 +45,36 @@
4645
BorderThickness="{TemplateBinding BorderThickness}"
4746
CornerRadius="{TemplateBinding CornerRadius}" />
4847

49-
<Grid x:Name="ContentRoot">
48+
<Grid x:Name="ContentRoot" MinWidth="40">
5049
<Grid.ColumnDefinitions>
5150
<ColumnDefinition Width="*" />
5251
<ColumnDefinition Width="Auto" />
5352
<ColumnDefinition Width="Auto" />
5453
</Grid.ColumnDefinitions>
55-
<Viewbox
56-
x:Name="ContentViewbox"
57-
Height="16"
58-
HorizontalAlignment="Stretch">
59-
<ui:ContentPresenterEx
60-
x:Name="Content"
61-
Content="{TemplateBinding Icon}"
62-
Foreground="{TemplateBinding Foreground}" />
63-
</Viewbox>
54+
<Grid x:Name="IconAndLabelPanel" VerticalAlignment="Center">
55+
<Grid.RowDefinitions>
56+
<RowDefinition Height="*" />
57+
<RowDefinition Height="Auto" />
58+
</Grid.RowDefinitions>
59+
<Viewbox x:Name="ContentViewbox" Height="16">
60+
<ui:ContentPresenterEx
61+
x:Name="Content"
62+
Content="{TemplateBinding Icon}"
63+
Foreground="{TemplateBinding Foreground}"/>
64+
</Viewbox>
65+
<TextBlock x:Name="TextLabel"
66+
Grid.Row="1"
67+
Text="{TemplateBinding Label}"
68+
Style="{DynamicResource CaptionTextBlockStyle}"
69+
Foreground="{TemplateBinding Foreground}"
70+
FontFamily="{TemplateBinding FontFamily}"
71+
TextAlignment="Center"
72+
TextTrimming="CharacterEllipsis"
73+
TextWrapping="Wrap"
74+
HorizontalAlignment="Center"
75+
Margin="0,6,0,2"
76+
Visibility="Collapsed" />
77+
</Grid>
6478
<TextBlock
6579
x:Name="OverflowTextLabel"
6680
Margin="12,0,12,0"
@@ -73,6 +87,7 @@
7387
Text="{TemplateBinding Label}"
7488
TextAlignment="Left"
7589
TextWrapping="NoWrap"
90+
TextTrimming="CharacterEllipsis"
7691
Visibility="Collapsed" />
7792
<TextBlock
7893
x:Name="KeyboardAcceleratorTextLabel"
@@ -90,10 +105,10 @@
90105
Grid.Column="2"
91106
Margin="12,0,12,0"
92107
VerticalAlignment="Center"
93-
FontFamily="{DynamicResource FluentSystemIcons}"
108+
FontFamily="{DynamicResource SymbolThemeFontFamily}"
94109
FontSize="12"
95110
Foreground="{DynamicResource CommandBarFlyoutAppBarButtonSubItemChevronForeground}"
96-
Glyph="&#xF2B0;"
111+
Glyph="&#xE76C;"
97112
Visibility="Collapsed" />
98113
</Grid>
99114
<VisualStateManager.VisualStateGroups>
@@ -137,6 +152,13 @@
137152
<VisualState x:Name="NoFlyout" />
138153
<VisualState x:Name="HasFlyout" />
139154
</VisualStateGroup>
155+
<VisualStateGroup x:Name="PrimaryLabelStates">
156+
<ui:VisualStateGroupListener.Listener>
157+
<ui:VisualStateGroupListener x:Name="PrimaryLabelStatesListener" />
158+
</ui:VisualStateGroupListener.Listener>
159+
<VisualState x:Name="NoPrimaryLabels" />
160+
<VisualState x:Name="HasPrimaryLabels" />
161+
</VisualStateGroup>
140162
</VisualStateManager.VisualStateGroups>
141163
</Grid>
142164
<ControlTemplate.Triggers>
@@ -154,6 +176,7 @@
154176
<Setter TargetName="ContentRoot" Property="MinHeight" Value="0" />
155177
<Setter TargetName="ContentRoot" Property="Width" Value="NaN" />
156178
<Setter TargetName="ContentViewbox" Property="Visibility" Value="Collapsed" />
179+
<Setter TargetName="TextLabel" Property="Visibility" Value="Collapsed" />
157180
<Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
158181
<Setter TargetName="OverflowTextLabel" Property="Margin" Value="39,0,12,0" />
159182
</Trigger>
@@ -166,6 +189,7 @@
166189
<Setter TargetName="ContentViewbox" Property="Width" Value="16" />
167190
<Setter TargetName="ContentViewbox" Property="Height" Value="16" />
168191
<Setter TargetName="ContentViewbox" Property="Margin" Value="12,0,12,0" />
192+
<Setter TargetName="TextLabel" Property="Visibility" Value="Collapsed" />
169193
<Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
170194
<Setter TargetName="OverflowTextLabel" Property="Margin" Value="39,0,12,0" />
171195
</Trigger>
@@ -178,6 +202,7 @@
178202
<Setter TargetName="ContentViewbox" Property="Width" Value="16" />
179203
<Setter TargetName="ContentViewbox" Property="Height" Value="16" />
180204
<Setter TargetName="ContentViewbox" Property="Margin" Value="39,0,12,0" />
205+
<Setter TargetName="TextLabel" Property="Visibility" Value="Collapsed" />
181206
<Setter TargetName="OverflowTextLabel" Property="Visibility" Value="Visible" />
182207
<Setter TargetName="OverflowTextLabel" Property="Margin" Value="67,0,12,0" />
183208
</Trigger>
@@ -187,16 +212,19 @@
187212
<Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="PointerOver">
188213
<Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPointerOver}" />
189214
<Setter TargetName="Content" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
215+
<Setter TargetName="TextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPointerOver}" />
190216
</Trigger>
191217
<!-- Pressed -->
192218
<Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Pressed">
193219
<Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundPressed}" />
194220
<Setter TargetName="Content" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
221+
<Setter TargetName="TextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundPressed}" />
195222
</Trigger>
196223
<!-- Disabled -->
197224
<Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Disabled">
198225
<Setter TargetName="AppBarButtonInnerBorder" Property="Background" Value="{DynamicResource CommandBarFlyoutAppBarButtonBackgroundDisabled}" />
199226
<Setter TargetName="Content" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
227+
<Setter TargetName="TextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
200228
<Setter TargetName="OverflowTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
201229
<Setter TargetName="KeyboardAcceleratorTextLabel" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonForegroundDisabled}" />
202230
<Setter TargetName="SubItemChevron" Property="Foreground" Value="{DynamicResource CommandBarFlyoutAppBarButtonSubItemChevronDisabledForeground}" />
@@ -234,6 +262,13 @@
234262
<Trigger SourceName="FlyoutStatesListener" Property="CurrentStateName" Value="HasFlyout">
235263
<Setter TargetName="SubItemChevron" Property="Visibility" Value="{DynamicResource AppBarButtonHasFlyoutChevronVisibility}" />
236264
</Trigger>
265+
<!-- HasPrimaryLabels -->
266+
<Trigger SourceName="PrimaryLabelStatesListener" Property="CurrentStateName" Value="HasPrimaryLabels">
267+
<Setter TargetName="IconAndLabelPanel" Property="Margin" Value="0,9,0,0" />
268+
<Setter TargetName="IconAndLabelPanel" Property="VerticalAlignment" Value="Top" />
269+
<Setter TargetName="IconAndLabelPanel" Property="Width" Value="60" />
270+
<Setter TargetName="TextLabel" Property="Visibility" Value="Visible" />
271+
</Trigger>
237272
</ControlTemplate.Triggers>
238273
</ControlTemplate>
239274
</Setter.Value>

source/iNKORE.UI.WPF.Modern.Gallery/Pages/Controls/Windows/CommandBarFlyoutPage.xaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,26 @@
1717
Label="Share"
1818
ToolTipService.ToolTip="Share">
1919
<ui:AppBarButton.Icon>
20-
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}"/>
20+
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Share}"/>
2121
</ui:AppBarButton.Icon>
2222

2323
</ui:AppBarButton>
2424
<ui:AppBarButton
2525
Click="OnElementClicked"
26-
Icon="Save"
2726
Label="Save"
28-
ToolTipService.ToolTip="Save" />
27+
ToolTipService.ToolTip="Save" >
28+
<ui:AppBarButton.Icon>
29+
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}"/>
30+
</ui:AppBarButton.Icon>
31+
</ui:AppBarButton>
2932
<ui:AppBarButton
3033
Click="OnElementClicked"
31-
Icon="Delete"
3234
Label="Delete"
33-
ToolTipService.ToolTip="Delete" />
35+
ToolTipService.ToolTip="Delete" >
36+
<ui:AppBarButton.Icon>
37+
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}"/>
38+
</ui:AppBarButton.Icon>
39+
</ui:AppBarButton>
3440
<ui:CommandBarFlyout.SecondaryCommands>
3541
<ui:AppBarButton Click="OnElementClicked" Label="Resize" />
3642
<ui:AppBarButton Click="OnElementClicked" Label="Move" />
@@ -51,6 +57,15 @@
5157
AutomationProperties.Name="mountain"
5258
Click="MyImageButton_Click"
5359
ContextMenuOpening="MyImageButton_ContextMenuOpening">
60+
<Button.ContextMenu>
61+
<ContextMenu>
62+
<ContextMenu.Template>
63+
<ControlTemplate TargetType="{x:Type ContextMenu}">
64+
<Line Visibility="Collapsed"/>
65+
</ControlTemplate>
66+
</ContextMenu.Template>
67+
</ContextMenu>
68+
</Button.ContextMenu>
5469
<Image
5570
x:Name="Image1"
5671
Height="300"

source/iNKORE.UI.WPF.Modern.Gallery/Pages/Controls/Windows/CommandBarFlyoutPage.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ private void OnElementClicked(object sender, RoutedEventArgs e)
3737

3838
private void ShowMenu(bool isTransient)
3939
{
40+
CommandBarFlyout1.ShowMode = isTransient ? FlyoutShowMode.Transient : FlyoutShowMode.Standard;
4041
CommandBarFlyout1.ShowAt(Image1);
4142
}
4243

4344
private void MyImageButton_ContextMenuOpening(object sender, ContextMenuEventArgs e)
4445
{
4546
// always show a context menu in standard mode
4647
ShowMenu(false);
48+
e.Handled = true;
4749
}
4850

4951
private void MyImageButton_Click(object sender, RoutedEventArgs e)
@@ -134,5 +136,10 @@ private void MyImageButton_Click(object sender, RoutedEventArgs e)
134136

135137
#endregion
136138

139+
private void OnRightMouseUp(object sender, MouseButtonEventArgs e)
140+
{
141+
// always show a context menu in standard mode
142+
//ShowMenu(false);
143+
}
137144
}
138145
}

0 commit comments

Comments
 (0)