I have a custom control I wrote in WPF, which has a Boolean dependency property:
public static readonly DependencyProperty IsAlertProperty
= DependencyProperty.Register("IsAlert", typeof(bool), typeof(AlertControl),
new FrameworkPropertyMetadata(default(bool),
FrameworkPropertyMetadataOptions.None,
OnIsAlertChanged,
null,
false,
UpdateSourceTrigger.PropertyChanged));
public bool IsAlert
{
get { return (bool)GetValue(IsAlertProperty); }
set { SetValue(IsAlertProperty, value); }
}
In my Generic.xaml, I have the following xaml code:
<Style TargetType="{x:Type local:AlertControl}">
<Setter Property="Template">
<Setter.Value> ... </Setter.Value>
</Setter>
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip Visiblity="{Binding Path=IsAlert,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource BooleanToVisiblityConverter}">
<!-- Tooltip content goes here -->
</ToolTip>
</Setter.Value>
</Setter>
<Style />
The problem is that this doesn't seem to work. I used Snoop to spy on my xaml, and the IsAlert
property is changing appropriately, but if I delve into my AlertControl.ToolTip
, I see that the Visiblity
DependencyProperty has a binding error. I also tried using RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AlertControl}}
, but that also gave a binding issue. I don't know how else to diagnose this because my output window is not spitting out any binding expression errors either.