标题解释它我想,我正在尝试以模板样式设置计算的多重绑定。
<Style TargetType="{x:Type controls:MyControl}">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource TimespanToWidth}">
<Binding Path="RangeLength" />
<Binding Path="TickWidth" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
任何解决方案?
编辑:
问题在于自定义标记扩展在代码中创建多重绑定。我错误地认为它无法通过
完成示例代码:
public override object ProvideValue(IServiceProvider serviceProvider)
{
var b = new MultiBinding();
b.Converter = new SimpleConverter();
b.Bindings.Add(new Binding("A"));
b.Bindings.Add(new Binding("B"));
return b.ProvideValue(serviceProvider);
}
更改为:
public override object ProvideValue(IServiceProvider serviceProvider)
{
var b = new MultiBinding();
b.Converter = new SimpleConverter();
b.Bindings.Add(new Binding("A"));
b.Bindings.Add(new Binding("B"));
return b;
}
这可能对其他人有帮助。