Sí, puede utilizar el control emergente, pero debe establecer la propiedad secundaria en un control de contenido que cubra la ventana completa de la aplicación Y cambie de tamaño cuando se cambie el tamaño de la ventana. No es difícil crear el tuyo propio.
crear un control con plantilla basada en una ContentControl:
public sealed class PopoverView : ContentControl
{
public PopoverView()
{
this.DefaultStyleKey = typeof(PopoverView);
Loaded += OnLoaded;
Unloaded += OnUnloaded;
}
/// <summary>
/// Measure the size of this control: make it cover the full App window
/// </summary>
protected override Size MeasureOverride(Size availableSize)
{
Rect bounds = Window.Current.Bounds;
availableSize = new Size(bounds.Width, bounds.Height);
base.MeasureOverride(availableSize);
return availableSize;
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
Window.Current.SizeChanged += OnSizeChanged;
}
private void OnSizeChanged(object sender, WindowSizeChangedEventArgs e)
{
InvalidateMeasure();
}
private void OnUnloaded(object sender, RoutedEventArgs e)
{
Window.Current.SizeChanged -= OnSizeChanged;
}
}
añadir este código a la Generic.xaml:
<SolidColorBrush x:Key="PopoverViewBackgroundThemeBrush">White</SolidColorBrush>
<!-- Semi-transparant black brush to cover the background: -->
<SolidColorBrush x:Key="PopoverViewOverlayThemeBrush">#80000000</SolidColorBrush>
<Style TargetType="local:PopoverView">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:PopoverView">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="{StaticResource PopoverViewOverlayThemeBrush}" />
<Border Grid.Row="1" Child="{TemplateBinding Content}" Background="{StaticResource PopoverViewBackgroundThemeBrush}" />
<Border Grid.Row="2" Background="{StaticResource PopoverViewOverlayThemeBrush}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Ahora puede crear un control de usuario con el PopoverView como contenido. Ejemplo:
<UserControl
x:Class="PopoverCustomControlTest.MyUserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PopoverCustomControlTest"
xmlns:custom="using:MyCustomControls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<custom:PopoverView>
<!-- Create your own dialog here instead of this simple button -->
<Button Content="Close PopoverView"
Click="Button_Click_1"
Background="Black"
HorizontalAlignment="Center"
Margin="40" />
</custom:PopoverView>
</UserControl>
public sealed partial class MyUserControl1 : UserControl
{
private Popup popup;
public MyUserControl1(Popup popup)
{
if (popup == null) throw new ArgumentNullException("popup");
this.popup = popup;
this.InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
this.popup.IsOpen = false;
}
}
y mostrarla cuando lo necesite:
Popup popup = new Popup();
popup.Child = new MyUserControl1(popup);
popup.IsOpen = true;
Crear un div gris translúcida que cubre la pantalla, a continuación, poner un sólido div gris en la parte superior de la misma. Dentro del div gris sólido, coloca tus controles. –
@RaymondChen, esta pregunta se trata de aplicaciones xaml/C#. No puede mezclar el marcado HTML con xaml. – KyleMit
@KyleMit s/div/panel/g. He hecho algo similar a esto al portar una aplicación js/html a C#/xaml. –