Can't get Tooltip to update
So I have a ToolTip on a Border. I've tried it several ways in XAML to make this work--this is the simplest:
I have INotifyPropertyChanged implemented on the ViewModel and OnPropertyChanged is firing for ToolTipText. But the ToolTip will just not update. It sticks with whatever is the value the first time it is opened.
Any ideas as to what I'm doing wrong or how I can get my ToolTip to update on a data change?
Thanks.
Code: Select all
<Border.ToolTip>
<Border BorderBrush="Black" BorderThickness="0" Background="OldLace">
<TextBlock Text="{Binding ToolTipText}" Foreground="Black" Padding="5" FontSize="18" />
</Border>
</Border.ToolTip>
Any ideas as to what I'm doing wrong or how I can get my ToolTip to update on a data change?
Thanks.
-
-
sfernandez
Site Admin
- Posts: 2062
- Joined:
Re: Can't get Tooltip to update
Which version of Noesis are you using, because the test I made seems to work just fine.
I took one of our samples like Inventory, added the following to the end of the MainWindow.xaml:
Modified ViewModel.cs to include the ToolTipText property:
And then added some code in the MainWindow code-behind to change the ToolTip text when the mouse is pressed:
Could you please try that and let us know if it works?
I took one of our samples like Inventory, added the following to the end of the MainWindow.xaml:
Code: Select all
<Border Grid.ColumnSpan="5" Grid.RowSpan="5" Width="200" Height="100" Background="Red" HorizontalAlignment="Left" VerticalAlignment="Top">
<Border.ToolTip>
<Border Background="OldLace">
<TextBlock Text="{Binding ToolTipText}" Foreground="Black" Padding="5" FontSize="18" />
</Border>
</Border.ToolTip>
</Border>
Code: Select all
public class ViewModel : NotifierBase
{
private string _tooltiptext;
public string ToolTipText
{
get { return _tooltiptext; }
set
{
if (_tooltiptext != value)
{
_tooltiptext = value;
OnPropertyChanged("ToolTipText");
}
}
}
...
}
Code: Select all
private void OnInitialized(object sender, EventArgs e)
{
DataContext = new ViewModel();
ViewModel vm = DataContext as ViewModel;
vm.ToolTipText = "Hello world";
this.PreviewMouseDown += (s, e_) =>
{
vm.ToolTipText = "ToolTip is changing: " + e_.GetPosition(null);
};
}
Re: Can't get Tooltip to update
I should have the latest Noesis. I will try what you posted. I thought I was already doing that.
I failed to mention that this was in Unity. Sorry-was posting really late.
I failed to mention that this was in Unity. Sorry-was posting really late.
Re: Can't get Tooltip to update
Ok, moral of the story--don't try to make sense of non-working code at 4AM. :)
This is working fine. I just had a really dumb error in my code. Thanks for looking at it, and I'm sorry for wasting your time.
This is working fine. I just had a really dumb error in my code. Thanks for looking at it, and I'm sorry for wasting your time.
-
-
sfernandez
Site Admin
- Posts: 2062
- Joined:
Re: Can't get Tooltip to update
Ok, marking this as solved.
Who is online
Users browsing this forum: Google [Bot] and 0 guests