Currently I am trying to bind the IsOpen
property of a ToolTip
to a property of my backing view model. Additionally The binding mode is set to 'OneWayToSource'.
This is the Style
that is applied to a TreeViewItem
and contains the ToolTip
definition:
<Style TargetType="TreeViewItem">
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip IsOpen="{Binding IsToolTipOpen, Mode=OneWayToSource}">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding CurrentValue, StringFormat={}Value: {0}}"/>
<TextBlock Text="{Binding UnitName, StringFormat={}Unit: {0}}"
Visibility="{Binding HasUnit, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</StackPanel>
</ToolTip>
</Setter.Value>
</Setter>
</Style>
Here is the code for the property that it is binding to:
public bool IsToolTipOpen
{
get
{
return mIsToolTipOpen;
}
set
{
PegasusContext.Current.LogMessage( new PegasusMessage( string.Format( "IsTooltipOpen: {0}", value ), LogLevel.Debug ) );
if( mIsToolTipOpen == value ) return;
mIsToolTipOpen = value;
if( mIsToolTipOpen )
{
BackingIO.BeginWatching();
}
else
{
BackingIO.StopWatching();
}
}
}
When the ToolTip is opened for the first time, it will invoke the IsToolTipOpen
property setting it's value to false
. Additionally when the ToolTip closes, it will set the value of IsToolTipOpen
to false
...again. Every subsequent time, the value will get set as expected. After opening the first ToolTip, it will perform strange behavior on other items with the ToolTip attached. For instance it will set the IsToolTipOpen
property to true
and then back to false
almost immediately. Again every subsequent time the ToolTip
is opened, it works normally.
Here is report from the logging code you can see on the first line of my IsToolTipOpen
property set method (with some additional comments I handwrote in):
TreeViewItem A:
IsTooltipOpen: False <-- ToolTip Opened
IsTooltipOpen: False <-- ToolTip Closed
IsTooltipOpen: True <-- ToolTip Opened
IsTooltipOpen: False <-- ToolTip Closed
TreeViewItem B:
IsTooltipOpen: True <-- ToolTip Open
IsTooltipOpen: False <-- ToolTip Open, occured at the same time as the previous entry.
IsTooltipOpen: False <-- ToolTip Closed
IsTooltipOpen: True <-- ToolTip Opened
IsTooltipOpen: False <-- ToolTip Closed
So I was curious if anyone had any idea what was going on? and possible solutions?