Wednesday, November 19, 2014

dynamic position of flyout?

I did something differently instead of using a canvas, I register a global right tapped event:



<Grid x:Name="mainGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Button" HorizontalAlignment="Left" Height="137" Margin="237,194,0,0" VerticalAlignment="Top" Width="305"/>

<Popup x:Name="myPopup" IsOpen="False">
<StackPanel>
<TextBlock Text="Type some input" FontSize="24.667" />
<TextBox Width="300" Height="55" />
<Button Content="Save" />
</StackPanel>
</Popup>
</Grid>




public MainPage()
{
this.InitializeComponent();

this.AddHandler(UIElement.RightTappedEvent,new RightTappedEventHandler(Grid_RightTapped),true);
}


private void Grid_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
Point rightTappedPosition = e.GetPosition(mainGrid);

myPopup.HorizontalOffset = rightTappedPosition.X;
myPopup.VerticalOffset = rightTappedPosition.Y;
myPopup.IsOpen = true;
myPopup.IsLightDismissEnabled = false;

}



--James




<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>

Thanks

MSDN Community Support



Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


No comments:

Post a Comment