Skip to content

Commit

Permalink
Fix AppBarButton text not center aligned
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Oct 30, 2024
1 parent 56b28a6 commit f636e80
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@
</Grid>
<ControlTemplate.Triggers>
<!--#region ApplicationViewStates-->
<!-- FullSize -->
<Trigger SourceName="ApplicationViewStatesListener" Property="CurrentStateName" Value="FullSize">
<Setter Property="TextBlock.TextAlignment" Value="Center" />
</Trigger>
<!-- Compact -->
<Trigger SourceName="ApplicationViewStatesListener" Property="CurrentStateName" Value="Compact">
<Setter TargetName="AppBarButtonInnerBorder" Property="Margin" Value="{DynamicResource AppBarButtonInnerBorderCompactMargin}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,18 @@
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel>
<local:ControlExample x:Name="Example1" HeaderText="An AppBarButton with a symbol icon.">
<!--I dont know but something's wrong here-->
<!--<local:ControlExample x:Name="Example2" HeaderText="An AppBarButton with a Image.">
<local:ControlExample.Example>
<StackPanel Orientation="Horizontal">
<!-- App bar button with symbol icon. -->
<ui:AppBarButton
x:Name="Button1"
Click="AppBarButton_Click"
Label="SymbolIcon" >
<ui:AppBarButton.Icon>
<ui:SymbolIcon Symbol="Like"/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<TextBlock
x:Name="Control1Output"
Margin="8,0,0,0"
VerticalAlignment="Center" />
</StackPanel>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String>
&lt;ui:AppBarButton Icon=&quot;Like&quot; Label=&quot;SymbolIcon&quot; Click=&quot;AppBarButton_Click&quot;/&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
<local:ControlExample x:Name="Example2" HeaderText="An AppBarButton with a bitmap icon.">
<local:ControlExample.Example>
<StackPanel Orientation="Horizontal">
<!-- App bar button with bitmap icon. -->
--><!-- App bar button with bitmap icon. --><!--
<ui:AppBarButton
x:Name="Button2"
Click="AppBarButton_Click"
Label="BitmapIcon">
<!--<ui:AppBarButton.Icon>
<ui:AppBarButton.Icon>
<ui:BitmapIcon UriSource="/iNKORE.UI.WPF.Modern.Gallery;component/Assets/Slices2.png" />
</ui:AppBarButton.Icon>-->
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<TextBlock
x:Name="Control2Output"
Expand All @@ -62,7 +39,7 @@
&lt;/ui:AppBarButton&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
</local:ControlExample>-->
<local:ControlExample x:Name="Example3" HeaderText="An AppBarButton with a font icon.">
<local:ControlExample.Example>
<StackPanel Orientation="Horizontal">
Expand All @@ -72,7 +49,7 @@
Click="AppBarButton_Click"
Label="FontIcon">
<ui:AppBarButton.Icon>
<ui:FontIcon FontFamily="Candara" Glyph="&#x03A3;" />
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Home}"/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<TextBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ private void CompactButton_Click(object sender, RoutedEventArgs e)
{
if (sender is ToggleButton toggle && toggle.IsChecked != null)
{
Button1.IsCompact =
Button2.IsCompact =
//Button1.IsCompact =
//Button2.IsCompact =
Button3.IsCompact =
Button4.IsCompact = (bool)toggle.IsChecked;
}
Expand All @@ -65,12 +65,6 @@ private void AppBarButton_Click(object sender, RoutedEventArgs e)

switch (name)
{
case "Button1":
Control1Output.Text = "You clicked: " + name;
break;
case "Button2":
Control2Output.Text = "You clicked: " + name;
break;
case "Button3":
Control3Output.Text = "You clicked: " + name;
break;
Expand All @@ -88,5 +82,22 @@ private void Save_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}

#region Example Code

public string Example3Xaml => @"
<ui:AppBarButton
x:Name=""Button3""
Click=""AppBarButton_Click""
Label=""FontIcon"">
<ui:AppBarButton.Icon>
<ui:FontIcon Icon=""{x:Static ui:SegoeFluentIcons.Home}""/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
";



#endregion
}
}

0 comments on commit f636e80

Please sign in to comment.