-
Notifications
You must be signed in to change notification settings - Fork 22
MultiBinding
L edited this page Dec 30, 2017
·
4 revisions
<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