欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當前位置:主頁 > 軟件編程 > C#教程 >

C#實現(xiàn)win10 uwp 右擊浮出窗在點擊位置

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點擊: 次

本文主要讓MenuFlyout出現(xiàn)在我們右擊位置。

我們一般使用的MenuFlyout寫在前臺,寫在Button里面,但是可能我們的MenuFlyout顯示的位置和我們想要的不一樣。

通過使用后臺寫ShowAt的方法,我們可以通過e.GetPosition獲得鼠標點擊位置,需要對函數(shù)傳入相對的元素,這個元素一般可以用我們點擊使用的元素,也可以使用我們的最外層Grid,這樣我們就可以獲得了鼠標位置,也就可以顯示我們的MenuFlyout在點擊位置。

我們建一個ListView,然后綁定后臺,在我們ListView要右擊顯示我們的浮出,要求我們的浮出在我們點擊位置。

MenuFlyout可以在后臺寫,當然寫在前臺也可以。

我們這寫在后臺,我們可以選擇Placement 顯示在我們元素的位置,但這不是我們鼠標點擊的位置,要顯示我們鼠標點擊的位置,其實也很簡單。我們可以從e.GetPosition(sender as UIElement)獲得鼠標位置,把這個給MenuFlyout我們的浮出顯示在我們鼠標點擊位置

<ListView ItemsSource="{x:Bind View.Str}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Background="#FFda2a5c" RightTapped="GridColection_OnRightTapped">
<TextBlock Text="{Binding}"></TextBlock>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

后臺寫

private void GridColection_OnRightTapped(object sender, RightTappedRoutedEventArgs e)
{
MenuFlyout myFlyout = new MenuFlyout();
MenuFlyoutItem firstItem = new MenuFlyoutItem { Text = "OneIt" };
MenuFlyoutItem secondItem = new MenuFlyoutItem { Text = "TwoIt" };
myFlyout.Items.Add(firstItem);
myFlyout.Items.Add(secondItem);
//if you only want to show in left or buttom 
//myFlyout.Placement = FlyoutPlacementMode.Left;
FrameworkElement senderElement = sender as FrameworkElement;
//the code can show the flyout in your mouse click 
myFlyout.ShowAt(sender as UIElement, e.GetPosition(sender as UIElement));
}

以上所述是小編給大家介紹的C#實現(xiàn)win10 uwp 右擊浮出窗在點擊位置,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對我們網(wǎng)站的支持!

上一篇:C#中給Excel添加水印的具體方法

欄    目:C#教程

下一篇:C#環(huán)形隊列的實現(xiàn)方法詳解

本文標題:C#實現(xiàn)win10 uwp 右擊浮出窗在點擊位置

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6235.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有