How to display tooltip in XAML?
13,235
To keep with your MVVM model I think it will be difficult to achieve with a tooltip. You could use a popup and bind the IsOpen property.
<TextBox Grid.Row="1" x:Name="folder"
Text="{Binding Path=FolderPath}"
ToolTip=""/>
</TextBox>
<Popup PlacementTarget="{Binding ElementName=folder}" IsOpen="{Binding IsFolderSelected, Mode=TwoWay}">
<Border Margin="1">
<TextBlock Background="White" Foreground="Black" Text="Please select folder"></TextBlock>
</Border>
</Popup>
Author by
DanilaNV
Updated on June 04, 2022Comments
-
DanilaNV almost 2 years
I'm writing an application using WPF MVVM. I have a view model with property IsFolderSelected like this:
public class SelectFolderViewModel : ViewModelBase { public bool IsFolderSelected { get { return _isFolderSelected; } set { if (_isFolderSelected == value) { return; } _isFolderSelected = value; RaisePropertyChanged(IsFolderSelectedPropertyName); } } }
And i have a TextBox element in XAML:
<TextBox Text="{Binding Path=FolderPath}" ToolTip="Please select folder"/>
How can i force display tooltip from the TextBox when property IsFolderSlected == false?