Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Font Size From Slider - Simple XAMLBinding

$
0
0

I want slider to change font size in other wpf controls.

I found a simple solution similar to below but could not get it to work. Can you help get it to work?

Thanks

<Window x:Class="FontSizeFromSlider"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="FontSizeFromSlider" Height="300" Width="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <Style x:Key="SliderFontSize">
                <Setter Property="Control.FontSize">
                    <Setter.Value>
                        <Binding Source="{x:Static Application.Current}" Path="fontSize"/>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <TextBox Style="{StaticResource SliderFontSize}" Grid.Row="0">Hello</TextBox>
        <Slider Name="fontSize" Minimum="10" Maximum="22" IsSnapToTickEnabled="True"  TickPlacement="TopLeft"
            Value="{Binding Source={x:Static Application.Current}, Path=fontSize, Mode=TwoWay}" Grid.Row="1"/>
    </Grid>
</Window>

Harlan Black


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>