我正在开发一个自定义控件,并希望将两个依赖项属性传递给控件样式的setter中的Multi Converter。我的转换器启动,但值显示为UnsetValues。
xmlns:custom="clr-namespace:WPFStyles.CustomControls"
xmlns:con="clr-namespace:WPFStyles.Converters">
<con:PopUpVisibilty x:Key="PopUpVisibility"/>
<Style TargetType="{x:Type custom:PopUpNotification}">
<Setter Property="MaxHeight" Value="150"/>
<Setter Property="MaxWidth" Value="250"/>
<Setter Property="Visibility">
<Setter.Value>
<MultiBinding Converter="{StaticResource PopUpVisibility}">
<Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type custom:PopUpNotification}}" Path="IsOpen"/>
<Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type custom:PopUpNotification}}" Path="Header"/>
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type custom:PopUpNotification}">
如何正确传递这些属性的任何帮助都会很棒。
答案 0 :(得分:3)
我希望这可行:
<MultiBinding Converter="{StaticResource PopUpVisibility}">
<Binding RelativeSource="{RelativeSource Self}" Path="IsOpen"/>
<Binding RelativeSource="{RelativeSource Self}" Path="Header"/>
</MultiBinding>