1、添加文字

<Window x:Class="WpfApp1.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:WpfApp1" xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" WindowStyle="ToolWindow" WindowStartupLocation="CenterScreen">

<Window.Resources>
<sys:String x:Key="myString">Hello world</sys:String>
</Window.Resources>

<Grid>
<TextBlock Height="24" Width="120" Background="LightBlue" Text="This is my world"/>
<TextBlock Text="{StaticResource ResourceKey=myString}" Margin="5"/>
</Grid>
</Window>

C# wpf入门3--标签扩展赋值_ide

2、变量尺

<Window x:Class="WpfApp1.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:WpfApp1" xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" WindowStyle="ToolWindow" WindowStartupLocation="CenterScreen">


<Grid>

<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="24"/>
<RowDefinition Height="24"/>
</Grid.RowDefinitions>


<TextBox x:Name="tb" Text="{Binding ElementName=sld ,Path=Value}"/>

<Slider x:Name="sld" Grid.Row="2" Value="50" Maximum="100" Minimum="0"/>

</Grid>
</Window>

C# wpf入门3--标签扩展赋值_xml_02