Question

I have the following snippet:

<StackPanel>
    <Popup>
        <TextBox ToolTip="Edit current date"/>
    </Popup>
    <Label "Current Date"/>
</StackPanel>

I want the popup to show when the StackPanel is clicked, and hidden when it (the Popup) loses focus.

I was wondering what would be the shortest way to write this in xaml.

Was it helpful?

Solution

To do this with an animation, use BooleanAnimationUsingKeyFrames. The example shows how to animate the IsEnabled property but will work equally well with Popup.IsOpen. (You'll need to scroll waaaay down to see the XAML example.) Take care about the FillBehavior so that the Popup doesn't animate back to being closed when the animation ends (unless of course this is what you want!).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top