我正在开发一个自定义控件,并希望在控件样式的 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}">
Run Code Online (Sandbox Code Playgroud)
关于如何正确传递这些属性的任何帮助都会很棒。
我希望这能奏效:
<MultiBinding Converter="{StaticResource PopUpVisibility}">
<Binding RelativeSource="{RelativeSource Self}" Path="IsOpen"/>
<Binding RelativeSource="{RelativeSource Self}" Path="Header"/>
</MultiBinding>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1198 次 |
| 最近记录: |