I'm trying to have a WPF ViewBox 'appearing' at the cursor position in a user control when the user right-clicks on the control. Right now, I have the code:
<!-- XAML -->
<Viewbox Width="100" Visibility="Collapsed" x:Name="actionBox">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<Button>Item ▼</Button>
<Button>Permute ▼</Button>
<Button>Generate ▼</Button>
</StackPanel>
</Viewbox>
and
/* C# */
private void setPanel_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
Point p = e.GetPosition(this);
actionBox.Margin = new Thickness(p.X, p.Y, 0, 0);
actionBox.Visibility = System.Windows.Visibility.Visible;
actionBox.BringIntoView();
}
The event does get fired, but nothing seems to happen. (The MouseRightButtonDown="..."
is in a different part of the XAML file.)
How would one go about writing this in WPF?