views:

17

answers:

1

I have two controls in a grid, an Ellipse and a Popup. The idea is that both of the controls are only displayed if the IsDirty property in a view model is true; if so, the Ellipse is green if the same view model IsValid and red if not, while the Popup displays messages if the user has the mouse over the popup.

The content and bindings for the Popup are correct, so I am wondering if I should be able to control whether it IsOpen or not by using a trigger in it's own style as in the code below.

Cheers,
Berryl

<Popup x:Name="dirtyPopup" AllowsTransparency="True" >
    <Popup.Style>
        <Style TargetType="Popup">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="IsOpen" Value="{Binding IsDirty}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Popup.Style>
    <Grid content goes here />
</Popup>
+1  A: 

I don't think you want to bind to IsMouseOver on the Popup. That will only be true if the mouse is over the Popup window itself, which can only happen if the Popup is already open, so you'll never be able to open it in the first place.

You probably want the Popup to be open if the mouse is over some other control, such as the Ellipse. The easiest way to do that is a ToolTip. If you set the ToolTip property on your Ellipse, then when the mouse is over the Ellipse a ToolTip popup window will be displayed. Something like this:

<Ellipse>
    <Ellipse.ToolTip>
        <Grid content goes here />
    </Ellipse.ToolTip>
</Ellipse>
Quartermeister
Oh yes - thanks!
Berryl
But do I need a Popup if I want to show a hyperlink that the user can click on as part of the content? Any tips on how to do that if so?
Berryl