Skip to content

Instantly share code, notes, and snippets.

@anderssonjohan
Created December 23, 2021 12:06
Show Gist options
  • Save anderssonjohan/2c9d8d01886c209aa42450170465141b to your computer and use it in GitHub Desktop.
Save anderssonjohan/2c9d8d01886c209aa42450170465141b to your computer and use it in GitHub Desktop.
XAML examples
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="Wheat">
<Grid>
<Canvas Width="16" Height="16" SnapsToDevicePixels="True" ClipToBounds="True">
<Canvas.Resources>
<SolidColorBrush x:Key="LevelBrush" Color="White"/>
<SolidColorBrush x:Key="NoLevelBrush" Color="Transparent"/>
<SolidColorBrush x:Key="LevelBarBorder" Color="Gray"/>
</Canvas.Resources>
<Border BorderBrush="{StaticResource LevelBarBorder}" Background="{StaticResource LevelBrush}" BorderThickness="1" Canvas.Top="12" Height="4" Width="4"/>
<Border BorderBrush="{StaticResource LevelBarBorder}" Background="{StaticResource LevelBrush}" BorderThickness="1" Canvas.Top="10" Canvas.Left="3" Height="6" Width="4"/>
<Border BorderBrush="{StaticResource LevelBarBorder}" Background="{StaticResource LevelBrush}" BorderThickness="1" Canvas.Top="8" Canvas.Left="6" Height="8" Width="4"/>
<Border BorderBrush="{StaticResource LevelBarBorder}" Background="{StaticResource NoLevelBrush}" BorderThickness="1" Canvas.Top="6" Canvas.Left="9" Height="10" Width="4"/>
<Border BorderBrush="{StaticResource LevelBarBorder}" Background="{StaticResource NoLevelBrush}" BorderThickness="1" Canvas.Top="4" Canvas.Left="12" Height="12" Width="4"/>
</Canvas>
</Grid>
</Page>
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas Width="80" Height="80" Name="canvas"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas.RenderTransform>
<RotateTransform Angle="0" CenterX="40" CenterY="40" />
</Canvas.RenderTransform>
<Canvas.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="canvas" Storyboard.TargetProperty="(Canvas.RenderTransform).(RotateTransform.Angle)" To="360" Duration="0:0:0.7" AutoReverse="False" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Canvas.Triggers>
<Ellipse Canvas.Top="0" Canvas.Left="30" Width="20" Height="20" Fill="#08000000"/>
<Ellipse Canvas.Top="10" Canvas.Left="50" Width="20" Height="20" Fill="#33000000"/>
<Ellipse Canvas.Top="30" Canvas.Left="60" Width="20" Height="20" Fill="#55000000"/>
<Ellipse Canvas.Top="50" Canvas.Left="50" Width="20" Height="20" Fill="#66000000"/>
<Ellipse Canvas.Top="60" Canvas.Left="30" Width="20" Height="20" Fill="#88000000"/>
<Ellipse Canvas.Top="50" Canvas.Left="10" Width="20" Height="20" Fill="#aa000000"/>
<Ellipse Canvas.Top="30" Canvas.Left="0" Width="20" Height="20" Fill="#cc000000"/>
<Ellipse Canvas.Top="10" Canvas.Left="10" Width="20" Height="20" Fill="#ff000000"/>
</Canvas>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment