2013-04-23 105 views
0

我有一個Wpf應用程序,我希望所有的窗口都是全屏幕和居中。我在每個構造函數中都加上了這個指令:絕對值的高度和寬度

WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; 

在我自己的電腦裏它是有效的。但在其他方面並不是因爲固定值。

<Window x:Class="IHM.Authentification" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="" Height="803" Width="1380px" ResizeMode="NoResize" Background="#FFE8EEF3" WindowState="Maximized" WindowStyle="None"> 

我想的是,高度和寬度的值將是動態的,獨立於PC的屏幕尺寸。

那麼我該如何解決這個錯誤呢?

回答

2

只是刪除固定值,並添加

WindowStartupLocation="CenterScreen" 

去除構造

<Window x:Class="IHM.Authentification" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
Title="" ResizeMode="NoResize" Background="#FFE8EEF3" WindowState="Maximized" WindowStyle="None" 
WindowStartupLocation="CenterScreen" 
> 
0

只有將WindowState = 「最大化」 會做