【问题标题】:How to multi-bind ProgressBar's value in wpf?如何在 wpf 中多绑定 ProgressBar 的值?
【发布时间】:2013-11-06 22:32:09
【问题描述】:

WPF 中有一个Multibinding 的概念,如果我们想绑定一些依赖多个值的 UI 控件,例如在 this 中的一个,这非常有用。

我正在尝试对ProgressBar 做同样的事情,就像我使用ProgressBar 来显示用户使用了多少存储空间,它取决于两个属性。

  1. 已用存储
  2. 总存储量

搜索后,我找不到将ProgressBarValue 属性与多个属性和自定义转换器绑定的方法。

类似的东西(只是一个概念)

<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>

但问题是在ProgressBar.Value 下没有像MultiBinding 这样的东西。那么问题来了,

有没有办法MultiBindProgressBarValue

【问题讨论】:

    标签: c# .net wpf xaml data-binding


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2019-11-12
      • 2020-08-25
      • 1970-01-01
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      • 2011-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多