IPad like overlay popup window
wpf, xaml
Solution
dowhilefor is correct, the Popup class is the way to go - I made a small sample project using a Popup with a custom control as the child. Of importance are the PlacementTarget and Placement fields of Popup, as they let you set where the popup appears. Hope this helps!
Custom control:
<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 with popup:
<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>
Code behind for the window:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void rect_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
thePopup.IsOpen = !thePopup.IsOpen;
}
}
Problem
how would one do an IPad like overlay window like this in WPF with XAML I thought about a toggle button to or an expander control. It would be nice if the panel is scaleable. I have the most trouble with the centric overlay that has different size then the button itself. Any help, links or resources would be great.