Wpf 使用标签扩展为对象的属性赋值。
1, 
 TextBlock
TextBlock
 Binding
Binding
 
使用标签扩展为对象的属性赋值。
如图:
代码如下:
 TextBlock
TextBlock1  <Window.Resources>
2 <sys:String x:Key="hellostring">HelloString</sys:String>
3
4 </Window.Resources>
5 <Grid>
6 <TextBlock Height="20" Width="300" Text="{StaticResource ResourceKey=hellostring}"/>
7
8 </Grid>
2 <sys:String x:Key="hellostring">HelloString</sys:String>
3
4 </Window.Resources>
5 <Grid>
6 <TextBlock Height="20" Width="300" Text="{StaticResource ResourceKey=hellostring}"/>
7
8 </Grid>
3,使用动态绑定扩展标签
  textbox的值随着滑块的滑动而改变。 
如图:
代码如下:
 Binding
Binding1  <Grid>
2 <Grid.RowDefinitions>
3 <RowDefinition Height="33"></RowDefinition>
4 <RowDefinition Height="4"></RowDefinition>
5 <RowDefinition Height="30"></RowDefinition>
6 </Grid.RowDefinitions>
7 <TextBox x:Name="tb" Text="{Binding ElementName=sld, Path=Value}" ></TextBox>
8 <Slider x:Name="sld" Grid.Row="2" Value="50" Maximum="100" Minimum="0"></Slider>
9 </Grid>
2 <Grid.RowDefinitions>
3 <RowDefinition Height="33"></RowDefinition>
4 <RowDefinition Height="4"></RowDefinition>
5 <RowDefinition Height="30"></RowDefinition>
6 </Grid.RowDefinitions>
7 <TextBox x:Name="tb" Text="{Binding ElementName=sld, Path=Value}" ></TextBox>
8 <Slider x:Name="sld" Grid.Row="2" Value="50" Maximum="100" Minimum="0"></Slider>
9 </Grid>
参考:Wpf扩展标签 
 
                    
                     
                    
                 
                    
                 

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号