In my WPF project I have a popup which I would like to appear through a click of a RepeatButton. I cannot get the Popup to close if I use a RepeatButton whereas if I change it to a Button it works fine.
Here is some sample code which does not work.
<RepeatButton x:Name="MyButton" Content="My Button" Click="MyButton_Click"/>
simply code behind.
private void MyButton_Click(object sender, RoutedEventArgs e)
{
this.Popup.IsOpen = true;
}
A test popup - with no positioning or anything.
<StackPanel>
<Popup x:Name="Popup" StaysOpen="False" Placement="Bottom">
<Grid Background="Blue" Width="200" Height="100"/>
</Popup>
</StackPanel>
If I simply change over to a button like the below code then the Popup will close when there is a click outside of the popup
<Button x:Name="MyButton" Content="My Button" Click="MyButton_Click"/>
I would very much like to keep my RepeatButton if there is some workaround for this.