2017-06-15 38 views
0

プログラムを実行すると、ウィンドウの右側に大きな黒い領域が表示され、その理由がわかりません。 Visual Studio 2017のXAMLファイルページのプレビューにはありません.Windows 7のコンピュータで1回実行しましたが、黒い部分はありませんでした(主にWindows 10)。問題は別のファイルにある可能性がありますが、見つけられません。たぶん誰かがいくつか提案しているかもしれない。おかげWPF:ウィンドウ内の右側の黒い領域

<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

+0

左または右ですか?あなたの心を作ってください:) –

+0

それは右にあった、申し訳ありません。私はそれを修正します。しかし、それ自体は固定されていますが、私はそれを固定したことを知りません。しかし、今私はこれが起こる前に起こった問題を持っています....それは私が望むより幅が広くなるように見える領域に集中しています。 – ejderuby

+0

XAMLの外で行ったことがあるはずです。 – ejderuby

答えて

0

は、ここで私は私がSizeToContent="WidthAndHeight"を削除し、300の高さを追加したときに(私も、私はそのコードを持っていないので、あなたのイベントハンドラを削除する必要がありましたし、何を得るのです私は、元の画像を持っていないので)Resourcesフォルダにゴミ画像を追加します。

enter image description here

それはあなたが探していたものにもっと似ていますか?また、SizeToContentを「Manual」に明示的に設定することもできます。

+0

ほとんどの場合、はいですが、私は望みますが、私はこのウィンドウの上のイメージの幅と同じ幅にする必要があります。左右に罫線がなく、幅を小さくしても幅は変わらない – ejderuby

関連する問題