码迷,mamicode.com
首页 > 其他好文 > 详细

MultiBinding

时间:2017-12-30 21:34:27      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:slider   tps   class   text   blank   yellow   maximum   .com   https   

<StackPanel>
    <Slider x:Name="sl1" Minimum="10" Maximum="100"/>
    <Slider x:Name="sl2" Minimum="10" Maximum="100"/>
    <Label x:Name="label13" Background="Yellow" Foreground="Black">
        <Label.Content>
            <TextBlock>
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}This is {0:N2} x {1:N2}">
                        <Binding ElementName="sl1" Path="Value" />
                        <Binding ElementName="sl2" Path="Value" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </Label.Content>
    </Label>
</StackPanel>

在上面的例子中,移动滑块,Label的两个值对应发生变化
用占位符把两个滑块的值拼接在一起
通过:N2来保留两位小数

示例代码

https://github.com/zLulus/NotePractice/tree/dev3/WPF/WpfDemo/MultiBinding

MultiBinding

标签:slider   tps   class   text   blank   yellow   maximum   .com   https   

原文地址:https://www.cnblogs.com/Lulus/p/8150951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!