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

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

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

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

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

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

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

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

我們建一個(gè)ListView,然后綁定后臺(tái),在我們ListView要右擊顯示我們的浮出,要求我們的浮出在我們點(diǎn)擊位置。

MenuFlyout可以在后臺(tái)寫,當(dāng)然寫在前臺(tái)也可以。

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

<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>

后臺(tái)寫

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#實(shí)現(xiàn)win10 uwp 右擊浮出窗在點(diǎn)擊位置,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對我們網(wǎng)站的支持!

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

欄    目:C#教程

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

本文標(biāo)題:C#實(shí)現(xiàn)win10 uwp 右擊浮出窗在點(diǎn)擊位置

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

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

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

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

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