我有一个窗口,我在其中添加一个新UserControl
的(带有图像),我只是想将控件置于屏幕中间(垂直和水平)。我只能让垂直的工作。我DockPanel
将从我的 CodeBehind 中交换内容,并希望在开始制作幻灯片 UI 之前显示此启动屏幕,这意味着内容是从 CodeBehind 设置的。
我的Window
:
<Window x:Class="GreenWebPlayerWPF.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="512" Width="853" WindowStyle="None" WindowState="Maximized" WindowStartupLocation="CenterScreen">
<DockPanel Width="Auto" Height="Auto" Name="TransitionContainer" Background="Black" Margin="0" LastChildFill="True"></DockPanel>
</Window>
我的UserControl
:
<UserControl x:Class="GreenWebPlayerWPF.FrontPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DockPanel Background="Black">
<Image Name="image1" Stretch="None" Source="/GreenWebPlayerWPF;component/gw.png" />
</DockPanel>
</UserControl>
请注意,我正在使用最大化/全屏。