Skip to content

Instantly share code, notes, and snippets.

@eeevans
Created March 25, 2023 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eeevans/23ea1ee547826cb457f13b0488598523 to your computer and use it in GitHub Desktop.
Save eeevans/23ea1ee547826cb457f13b0488598523 to your computer and use it in GitHub Desktop.
XAML for window that creates buttons that have a binding for FontSize
<Window x:Class="Wpf.Binding.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Wpf.Binding"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="FontSize" Value="{Binding FontSizeLabel}" />
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Row="0" x:Name="AddButton" Click="AddButton_Click">Add Button</Button>
<Button Grid.Row="1" x:Name="ToggleSizeButton" Margin="0 5" Click="ToggleSizeButton_Click">Toggle Size Button</Button>
<ItemsControl Grid.Row="2" x:Name="ButtonList">
<Button>Existing Button</Button>
</ItemsControl>
</Grid>
</Window>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment