Files
ShrlAlgoToolkit/WPFluent.Gallery/Controls/ControlExample.xaml
2025-04-24 20:56:44 +08:00

104 lines
5.1 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:WPFluent.Gallery.Controls"
xmlns:helpers="clr-namespace:WPFluent.Gallery.Helpers"
xmlns:ui="https://github.com/ShrlAlgo/WPFluent">
<helpers:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
<Style TargetType="{x:Type controls:ControlExample}">
<Setter Property="Focusable" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:ControlExample}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ui:TextBlock
Grid.Row="0"
Margin="0,0,0,10"
FontTypography="BodyStrong"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="{TemplateBinding HeaderText}"
Visibility="{TemplateBinding HeaderText,
Converter={StaticResource NullToVisibilityConverter}}" />
<Border
Grid.Row="1"
Padding="16"
Background="{ui:ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ui:ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1,1,1,0"
CornerRadius="8,8,0,0">
<ContentPresenter Content="{TemplateBinding ExampleContent}" />
</Border>
<ui:CardExpander
Grid.Row="2"
CornerRadius="0,0,8,8"
Header="Source code">
<StackPanel>
<StackPanel x:Name="XamlCodeBlock">
<ui:TextBlock
Margin="0,0,0,5"
FontTypography="BodyStrong"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="XAML" />
<ui:CodeBlock
Padding="0"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0"
Content="{TemplateBinding XamlCode}" />
</StackPanel>
<Border
x:Name="Border"
Margin="0,20"
BorderThickness="1"
Visibility="Visible" />
<StackPanel x:Name="CsharpCodeBlock">
<ui:TextBlock
Margin="0,0,0,5"
FontTypography="BodyStrong"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="C#" />
<ui:CodeBlock
Padding="0"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0"
Content="{TemplateBinding CsharpCode}" />
</StackPanel>
</StackPanel>
</ui:CardExpander>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="XamlCode" Value="{x:Null}">
<Setter TargetName="XamlCodeBlock" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Border" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="CsharpCode" Value="{x:Null}">
<Setter TargetName="CsharpCodeBlock" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Border" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>