I have two radio buttons (RadioButton1 and RadioButton2). I need to display appropriate popup message when mouse is over one of the radio button. Hence I have following requirements
Requirement 1: When mouse is over "Radio Button 1" pop up message should be "Radio Button 1 is clicked". Similarly when mouse is over "Radio Button 2" pop up message should be "Radio Button 2 is clicked" .
Requirement 2: When mouse is clicked outside pop up control, pop up should close.
Requirement 3: Pop up also has hyperlink that displays a webpage when clicked. for this reason it should stay open.
To fulfill above requirements, i have used WPF pop up control with following settings
<Popup IsOpen="{Binding IsPopupOpen, Mode=TwoWay}" AllowsTransparency="True" PopupAnimation="Slide" StaysOpen="False" Placement="Bottom" >
<TextBlock Text="{Binding RadioButtonContent, Mode=OneWay}" />
IsPopupOpen & RadioButtonContent are MVVM ViewModel properties that are updated when "MouseEnter" (used interaction trigger)event happens on one of radio button.
However i have encountered following issue.
When moving mouse from Radio Button 1 (at this time pop up is opened to Radio Button2, Pop up does not show "Radio Button 2 is clicked". It still shows "Radio Button 1 is clicked "!!!.
After reading the documentation for Popup in MSDN, i found the this is the correct behaviour, since whenever pop is opened, Mouse capture is with pop up content (TextBlock in this case). Hence "MouseEnter" event for RadioButton2 is not fired, even though mouse is over Radiobutton 2.
Note: I cannot make StaysOpen="True" since it will not close clicking outside pop up parent. (Requirement 2 fails) I cannot use controls like "Tooltip" or "adorner" since it wont stay. (requirement 3 fails)
How can i satisfy all 3 requirements?
Popup
and add aTextBlock
which contains aHyperlink
as its child element. Then use anEventTrigger
that triggers onRadioButton.MouseEnter
and animate thePopup.IsOpen
property to show thePopup
. – BionicCodePopup
elements (one for eachRadioButton
). OnRadioButton.MouseEnter
always close the other popup(s) by animatingPopup.IsOpen
toFalse
. During the same animation timeline show the currentPopup
. This way they will behave mutual exclusive. – BionicCode