maui-linux/Xamarin.Forms.Platform.WPF/Themes/FormsAppBar.xaml

94 строки
5.4 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Xamarin.Forms.Platform.WPF.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Xamarin.Forms.Platform.WPF;component/Assets/Button.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:FormsAppBar">
<Setter Property="Background" Value="{DynamicResource AccentColor}"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Padding" Value="0" />
<Setter Property="Height" Value="60" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="controls:FormsAppBar">
<Grid VerticalAlignment="Stretch" Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter Grid.ColumnSpan="3"/>
<ItemsControl Name="PART_Command" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Stretch"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Focusable="False" UseLayoutRounding="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Setter
Property="ItemsSource"
Value="{Binding PrimaryCommands, RelativeSource={RelativeSource AncestorType={x:Type controls:FormsAppBar}}}" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=PART_More, Path=IsChecked}" Value="True">
<Setter
Property="ItemsSource"
Value="{Binding SecondaryCommands, RelativeSource={RelativeSource AncestorType={x:Type controls:FormsAppBar}}}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ItemsControl.Style>
</ItemsControl>
<ToggleButton Name="PART_More" Grid.Column="2" >
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource AppBarToggleButtonStyle}">
<Setter Property="Content">
<Setter.Value>
<controls:FormsSymbolIcon Symbol="More" FontSize="25" />
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True" >
<Setter Property="Content">
<Setter.Value>
<controls:FormsSymbolIcon Symbol="Cancel" FontSize="25" />
</Setter.Value>
</Setter>
</Trigger>
<DataTrigger
Binding="{Binding SecondaryCommands.Count, RelativeSource={RelativeSource AncestorType={x:Type controls:FormsAppBar}}}" Value="0">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
</Grid>
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Content, RelativeSource={RelativeSource Self}}" Value="{x:Null}" />
<Condition Binding="{Binding PrimaryCommands.Count, RelativeSource={RelativeSource Self}}" Value="0" />
<Condition Binding="{Binding SecondaryCommands.Count, RelativeSource={RelativeSource Self}}" Value="0" />
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Collapsed" />
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>