第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何讓Popup出現(xiàn)在特定的角落

如何讓Popup出現(xiàn)在特定的角落

C#
明月笑刀無情 2023-08-13 16:15:53
我希望我的Popup始終出現(xiàn)在特定的角落(例如右下角),無論我的View.我嘗試使用HorizontalAlignment但VerticalAlignment它并沒有真正起作用。這是我的代碼:<Grid x:Name="Output" HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="1">    <Popup x:Name="StandardPopup">        <Border BorderBrush="{StaticResource ApplicationForegroundThemeBrush}"             Background="{StaticResource ApplicationPageBackgroundThemeBrush}"            BorderThickness="2" Width="500" Height="500">            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">                <WebView x:Name="WebView1" Source="https://www.bing.com/" Width="490" Height="490" HorizontalAlignment="Center"/>            </StackPanel>        </Border>    </Popup></Grid>
查看完整描述

2 回答

?
qq_遁去的一_1

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊

您可以創(chuàng)建一個(gè) UserControl 來幫助您實(shí)現(xiàn)這一目標(biāo)。


創(chuàng)建一個(gè)名為 TestPopup 的新 UserControl


<UserControl

    ...

    >


    <Grid>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Bottom">

            <Border BorderBrush="{StaticResource ApplicationForegroundThemeBrush}" 

            Background="{StaticResource ApplicationPageBackgroundThemeBrush}"

            BorderThickness="2" Width="500" Height="500">

                <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">

                    <WebView x:Name="WebView1" Source="https://www.bing.com/" Width="490" Height="490" HorizontalAlignment="Center"/>

                </StackPanel>

            </Border>

        </Grid>

    </Grid>


</UserControl>

后臺(tái)代碼:


public sealed partial class TestPopup : UserControl

{

    private Popup _popup = null;

    public TestPopup()

    {

        this.InitializeComponent();

        // If you need to top placement, please comment out the Width/Height statement below

        this.Width = Window.Current.Bounds.Width;

        this.Height = Window.Current.Bounds.Height;


        //Assign the current control to the Child property of the popup. The Child property is what the popup needs to display.

        _popup = new Popup();

        _popup.Child = this;

    }

    public void ShowPopup()

    {

        _popup.IsOpen = true;

    }

    public void HidePopup()

    {

        _popup.IsOpen = false;

    }

}

在需要時(shí)使用 C# 代碼引用


public sealed partial class MainPage : Page

{

    private TestPopup _popup = new TestPopup();

    public MainPage()

    {

        this.InitializeComponent();

        _popup.ShowPopup();

    }

}

保證任意寬度下都在右下角,可以監(jiān)聽頁面的SizeChanged事件。


private void Page_SizeChanged(object sender, SizeChangedEventArgs e)

{

    _popup.Width = Window.Current.Bounds.Width;

    _popup.Height = Window.Current.Bounds.Height;

    // If you need to use the Width/Height of the page

    // _popup.Width = e.NewSize.Width;

    // _popup.Height = e.NewSize.Height;

}

此致。


查看完整回答
反對(duì) 回復(fù) 2023-08-13
?
慕少森

TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個(gè)贊

遺憾的是彈出窗口不支持對(duì)齊方式,您必須使用偏移值

注意:不要忘記您可以使用偏移綁定,從而通過一些轉(zhuǎn)換器魔法獲得您想要的行為。

<Popup?HorizontalOffset="20"?
???????VerticalOffset="10">
????<!--Content-->
????</Popup>


查看完整回答
反對(duì) 回復(fù) 2023-08-13
  • 2 回答
  • 0 關(guān)注
  • 177 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)