2

前几天我问过这个问题。现在,我正在尝试应用相同的做法来制作所有 my windows,并拥有CenterScreen默认的WindowStartupLocation. 我试过输入:

<Style TargetType="Window">
    <Setter Property="WindowStartupLocation">

    </Setter>
</Style>

但是,显然WindowStartupLocation这不是受支持的属性。有没有办法完成我所缺少的这一点,还是我必须为所有人手动更改它windows

4

1 回答 1

-1

应用程序.xaml

<Application.Resources>
    <ResourceDictionary>
        <Style x:Key="WindowStyle" TargetType="Window">
            <Setter Property="SizeToContent" Value="WidthAndHeight" />
            <Setter Property="ResizeMode" Value="CanMinimize" />
        </Style>
        <WindowStartupLocation x:Key="WSL">CenterOwner</WindowStartupLocation>
    </ResourceDictionary>
</Application.Resources>

窗户

<Window x:Class="WpfApplication7.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="MainWindow"        Width="525"        Height="350"        WindowStartupLocation="{StaticResource WSL}"        Style="{StaticResource WindowStyle}">
    <Window.Resources />
    <Grid />
</Window>
于 2013-05-28T15:06:33.023 回答