tags:

views:

29

answers:

1

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?

+1  A: 

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=""/>
    </StackPanel>

    <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>
Leigh Shayler
Popup! Thank you!
DanilaNV