Greuh
Greuh

Reputation: 11

WPF Horizontal alignement stretch but cannot set Window width to 100%

I have a simple Window that i would like to have a 100% width. I tried the "Stretch" property for Horizontal alignement but width is still stuck to 768.

<Window x:Class="WPF.View.MetroMsgBox"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MetroMsgBox" ShowInTaskbar="True"
        WindowStyle="None" ResizeMode="NoResize" 
        FontFamily="Segoe UI" Background="{x:Null}"
        AllowsTransparency="True" 
        Height="135"  WindowStartupLocation="CenterScreen"
        Deactivated="MetroMsgBox_OnDeactivated" HorizontalAlignment="Stretch" >

Upvotes: 0

Views: 66

Answers (1)

MRebai
MRebai

Reputation: 5474

Hi could you just try that :

Xaml

<Window x:Class="WPF.View.MetroMsgBox"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MetroMsgBox" ShowInTaskbar="True"
        Name=_window
        WindowStyle="None" ResizeMode="NoResize" 
        FontFamily="Segoe UI" Background="{x:Null}"
        AllowsTransparency="True" 
        Height="135"  WindowStartupLocation="CenterScreen"
        Deactivated="MetroMsgBox_OnDeactivated" HorizontalAlignment="Stretch" >

Code Behind

InitializeComponent();
_window.Width = Screen.PrimaryScreen.Bounds.Width;

Upvotes: 1

Related Questions