WPF-Control/WPF绑定元素-1-示例/MainWindow.xaml

24 lines
1.4 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<Window x:Class="WPF元素绑定_1_示例.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"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<StackPanel>
<Slider Name="SliderFontSize" Minimum="1" Maximum="100" Value="40" TickFrequency="1" TickPlacement="TopLeft" />
<Label>
Binding 绑定元素 ElementName=SliderFontSize 指定元素名称,Path=Value 指定绑定的值
</Label>
<TextBlock Margin="10" Text="简单的文字" Name="TextBlockShow"
FontSize="{Binding ElementName=SliderFontSize,Path=Value,Mode=TwoWay}" />
<WrapPanel>
<Button Margin="5 0" Padding="15 5" Name="SetSmall" Click="SetSmall_OnClick">设置小号</Button>
<Button Margin="5 0" Padding="15 5" Name="SetNormal" Click="SetNormal_OnClick">设置默认</Button>
<Button Margin="5 0" Padding="15 5" Name="SetLarge" Click="SetLarge_OnClick">设置大号</Button>
<Label>不要直接设置在字体上会使用字面绑定代替元素绑定或者使用Mode为TwoWay</Label>
</WrapPanel>
</StackPanel>
</Window>