IRezzet
IRezzet

Reputation: 13

Windows WPF elements do not show

Why do I see one thing in design mode and another during runtime?


On a Wpf Program one of my pages looks like this:

<Window x:Class="pPP_2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:pPP_2"
        mc:Ignorable="d"
        Title="MainWindow" Height="1080" Width="1920"
        WindowStyle="ThreeDBorderWindow"
        WindowState="Normal"

    xmlns:System="clr-namespace:System;assembly=System.Runtime">
    <Grid x:Name="MainWindowGrid">
        <Grid>
            <Frame x:Name="Pages" NavigationUIVisibility="Hidden" Background="Transparent"/>
            <Button x:Name="start" Background="LightGreen" Content="Simulation Starten" FontSize="20" Click="Go" Margin="710,394,710,508"/>
            <Button x:Name="factoryManage" Background="LightGreen" Content="Fabrik Verwalten" FontSize="20" Click="ManageFactory" Visibility="Visible" Margin="710,590,710,317"/>
            <Button Background="LightYellow" Content="Back" Margin="1550,55,219,968" BorderThickness="4,4,4,4" Click="backButton" Width="auto"/>
            <Button Background="LightYellow" Content="Exit" Margin="1701,55,68,967" BorderThickness="4,4,4,4" Click="Exit" Width="auto"/>
            <TextBox x:Name="Description" Margin="72,44,1610,956" Text="kp-cpps-sim2k19" TextWrapping="Wrap">
                <TextBox.Resources>
                    <Style TargetType="TextBox">
                        <Setter Property="VerticalContentAlignment" Value="Center"/>
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                    </Style>
                </TextBox.Resources>
            </TextBox>
            <Button Content="Zurück zur Startseite" Margin="748,53,748,966" Click="Button_Click_2"/>
            <Button x:Name="Inventory" Content="Inventar" Margin="48,925,1586,52" Click="InventarClick"/>

        </Grid>
    </Grid>
</Window>

Picture

Image Link

Why during runtime does the window just goes all white with nothing being shown?

Upvotes: 0

Views: 293

Answers (2)

Ribaz
Ribaz

Reputation: 676

Your page size is large Height="1080" Width="1920". You have zoomed out the window in the design view that is why you can see the whole window, but when you run it. When you resize it and you have set big margin values for THE buttons and others. Try to use grid properly with row and column definition.

Upvotes: 1

ΩmegaMan
ΩmegaMan

Reputation: 31686

Remove the outlandish margins such as Margin="72,44,1610,956" and place controls via grid rows/columns which will size accordingly to window height/width based on screen size.

Upvotes: 0

Related Questions