一个控件的多个参数被绑定

前台代码<xaml>
<Window x:Class="WpfApplication4.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" WindowState="Normal" WindowStartupLocation="CenterScreen">
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Slider Name="sliderFontSize" Grid.Row="0" Margin="3" Minimum="1" Maximum="40" Value="10"></Slider>
        <TextBox Name="txtContent" Margin="3" Grid.Row="1">Sample Content</TextBox>
        <ListBox Margin="3" Grid.Row="2" Name="lstColors">
            <ListBoxItem Tag="Blue">Blue</ListBoxItem>
            <ListBoxItem Tag="DarkBlue">DarkBlue</ListBoxItem>
            <ListBoxItem Tag="Light Blue">Light Blue</ListBoxItem>
        </ListBox>
        <TextBlock Grid.Row="3" Name="lbSampleText"
                   FontSize="{Binding ElementName=sliderFontSize,Path=Value}"
                   Text="{Binding ElementName=txtContent,Path=Text}"
                   Foreground="{Binding ElementName=lstColors,Path=SelectedItem.Tag}"></TextBlock>
    </Grid>
</Window>

单片机,嵌入式LINUX技术交流群:142282597
原文地址:https://www.cnblogs.com/qiujiahong/p/3173306.html