我有一個窗口,我添加一個新的UserControl
(與一個圖像),我只是想中央控制在屏幕中間(垂直和水平)。我只能得到垂直的工作。我將從我的CodeBehind中交換DockPanel
的內容,並希望在我開始製作幻燈片用戶界面之前顯示此啓動屏幕,這意味着內容是從CodeBehind設置的。居中一個WPF控件
我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>
請注意,我使用的最大化/全屏。
THX一堆,它的工作原理:-) – H4mm3rHead 2009-08-21 20:08:26
這不能在Windows RT – 2013-07-27 14:22:44
的基於XAML的框架,用於在RT寫商店Apps並非WPF工作。如果有的話,它更多的是Silverlight派生。 – 2013-07-29 16:50:45