Reputation: 135
I am developing a custom control and want to pass a two dependency properties to a Multi Converter in a setter on the control style. My converter kicks in, but the values are showing as 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}">
Any help on how to pass these properties correctly would be great.
Upvotes: 4
Views: 2111
Reputation: 37059
I would expect this to work:
<MultiBinding Converter="{StaticResource PopUpVisibility}">
<Binding RelativeSource="{RelativeSource Self}" Path="IsOpen"/>
<Binding RelativeSource="{RelativeSource Self}" Path="Header"/>
</MultiBinding>
Upvotes: 6