1

There is a concept of Multibinding in WPF, which is really useful if we want to bind some UI Control that depends on multiple values, like in this one.

I am trying to do the same with ProgressBar, like I am using ProgressBar to display how much storage is used by the users and it depends on two properties.

  1. UsedStorage
  2. TotalStorage

After searching, i could not find a way to bind Value property of ProgressBar with multiple properties and custom convertor.

Something like (Just a concept)

<ProgressBar Width="172" Height="16" >
    <ProgressBar.Value>
        <MultiBinding Converter="{StaticResource myConverter}">
            <Binding  Path="UsedStorage" RelativeSource="{RelativeSource AncestorType={x:Type Window}}"/>
            <Binding  Path="TotalStorage"  RelativeSource="{RelativeSource AncestorType={x:Type Window}}"/>
        </MultiBinding>
    </ProgressBar.Value>
</ProgressBar>

But problem is there is nothing like MultiBinding under ProgressBar.Value. So the question is,

Is there a way to MultiBind ProgressBar Value?

4

1 回答 1

3

尽管 Visual Studio 智能感知可能不会显示,但它是完全有效的。

但是, UsingRelativeSource TemplatedParent仅适用于ControlTemplate. 我不清楚你想从哪里得到你的价值观。

于 2013-11-06T22:35:07.707 回答