gpt4 book ai didi

wpf - iPad 之类的叠加弹出窗口

转载 作者:行者123 更新时间:2023-12-04 14:22:17 26 4
gpt4 key购买 nike

关闭。这个问题需要更多focused .它目前不接受答案。












想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post .

2年前关闭。




Improve this question




一个像这样的覆盖窗口的 iPad 怎么做
在 WPF 中使用 XAML
enter image description here

我想到了一个切换按钮或一个扩展器控件。
如果面板是可缩放的,那就太好了。
我最麻烦的是中心覆盖层的大小与按钮本身的大小不同。

任何帮助、链接或资源都会很棒。

最佳答案

dowhilefor 是正确的, Popup 类是要走的路 - 我使用带有自定义控件的 Popup 作为子项制作了一个小型示例项目。重要的是 Popup 的 PlacementTarget 和 Placement 字段,因为它们可以让您设置弹出窗口的显示位置。希望这可以帮助!

Popup example

自定义控件:

<UserControl x:Class="SilverfighterTest.PopupControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="Margin" Value="4"/>
<Setter Property="Padding" Value="7"/>
</Style>
</UserControl.Resources>
<Grid Background="Gray">
<StackPanel>
<Button>Clone</Button>
<Button>Log Call</Button>
<Button> Visit Report</Button>
<Button> Delete</Button>
<Button>Cancel</Button>
</StackPanel>

</Grid>
</UserControl>

弹出窗口:
<Window x:Class="SilverfighterTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:SilverfighterTest"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Rectangle VerticalAlignment="Top" Name="rect" MouseLeftButtonDown="rect_MouseLeftButtonDown" HorizontalAlignment="Right" Height="50" Width="50" Fill="Red">

</Rectangle>

<Popup PopupAnimation="Slide" Placement="Bottom" PlacementTarget="{Binding ElementName=rect}" Name="thePopup" >
<local:PopupControl/>
</Popup>
</Grid>

窗口背后的代码:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

}

private void rect_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
thePopup.IsOpen = !thePopup.IsOpen;
}
}

关于wpf - iPad 之类的叠加弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10462539/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com