ejderuby
ejderuby

Reputation: 735

Black area to the right, inside window

A large black area appears on the right side of the window when I run the program, and I can't figure out why. It's not there in the preview on the XAML file page in Visual Studio 2017, and I ran it once on a Windows 7 computer, and the black area wasn't there (I'm primarily on Windows 10). The problem could possibly be in another file, but I cannot find it.

<Window x:Class="Project.Widget"
    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:Project"
    mc:Ignorable="d"

    Title="Menu" 
    WindowStartupLocation="Manual" 
    ResizeMode="NoResize" 
    Width="109" 
    SizeToContent="WidthAndHeight" 
    WindowState="Minimized" 
    Background="#2D3A48" 
    Topmost="False" 
    Loaded="Window_Loaded" 
    Closing="Window_Closing" >

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="77"/>
        <RowDefinition Height="28"/>
        <RowDefinition Height="90"/>
        <RowDefinition Height="60"/>
    </Grid.RowDefinitions>

    <Image x:Name="Icon"
           Source="./Resources/Icon.png" 
           HorizontalAlignment="Center" 
           VerticalAlignment="Top" 
           Height="77" 
           Width="109" />

    <Label x:Name="labelUsername"
           Grid.Row="1"
           Content=""
           FontSize="14"
           Foreground="White" 
           HorizontalContentAlignment="Center"
           VerticalContentAlignment="Center" />

    <Label x:Name="labelScore"
           Grid.Row="2"
           Content="0%, 0 of 0"
           Foreground="White"
           FontSize="14"
           HorizontalAlignment="Center"
           VerticalAlignment="Top"
           Margin="0,0,0,0" />

    <Image x:Name="AvgScoreDot"
           Grid.Row="2"
           HorizontalAlignment="Center"
           VerticalAlignment="Top"
           Height="50"
           Source=".\Resources\yellow_dot.png"
           Margin="0,32,0,0"/>

    <Label x:Name="labelAvgScore"
           Grid.Row="2"
           Content="0.0"
           Foreground="White"
           FontSize="24"
           HorizontalAlignment="Center"
           VerticalAlignment="Top"
           Margin="0,35,0,0" 
           FontWeight="Bold" />

    <Button x:Name="MailBtn"
            Grid.Row="3"
            Height="60"
            Width="109"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            BorderBrush="#FF2D3A48" 
            Click="Mail_Click" >
        <Button.Background>
            <ImageBrush 
                ImageSource="/Resources/mail.png" 
                Stretch="None" />
        </Button.Background>
    </Button>

    <Button x:Name="MailBadgeBtn"
           Grid.Row="3"
           Content="0"
           Foreground="White"
           FontSize="11"
           HorizontalContentAlignment="Center"
           VerticalContentAlignment="Center"
           Height="20"
           Width="20" 
           Margin="0,30,24,10" 
           HorizontalAlignment="Right"
           VerticalAlignment="Center" 
           Click="MailBadgeBtn_Click" BorderThickness="0">
        <Button.Background>
            <ImageBrush 
                ImageSource=".\Resources\red_dot.png" />
        </Button.Background>
    </Button>

    <TextBlock x:Name="labelConnection" 
               Grid.Row="0" 
               Text="                             No Connection      or blocked by Firewall" 
               Foreground="Red" 
               Background="White" 
               TextWrapping="Wrap" 
               TextAlignment="Center" 
               VerticalAlignment="Center" 
               Height="77" 
               Width="109" 
               HorizontalAlignment="Center" />
</Grid>

Here's an image of what I get when I run it:

image

Upvotes: 0

Views: 467

Answers (1)

NH.
NH.

Reputation: 2401

Here's what I get when I remove SizeToContent="WidthAndHeight" and add a height of 300 (I also had to remove your event handlers since I don't have that code, and add garbage images to the Resources folder since I don't have the original images):

enter image description here

Is that more like what you were looking for? You can also choose to explicitly set SizeToContent to "Manual".

Upvotes: 1

Related Questions