私は現在wpfアプリケーションを作成しようとしています。 問題は、私は、白い矩形を取得するだけのアプリケーションを実行するときです。 私は多くを検索しましたが、エラーが表示されません。XAMLアプリが表示されないのはなぜですか
私はwpfの初心者ですので、他にもいくつかのエラーがある場合は、より良いやり方を教えてください。感謝!
ここにxamlコードがあります。
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Test.Visu"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Test.Visu.MainWindow"
Title="MainWindow" Height="600" Width="800" Topmost="True" WindowStyle="None" SnapsToDevicePixels="True"
Left="0" Top="0">
<Window.Resources>
<ObjectDataProvider x:Key="date" ObjectType="{x:Type sys:DateTime}"/>
</Window.Resources>
<Grid x:Name="MainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="65"/>
<RowDefinition Height="*" MinHeight="250"/>
<RowDefinition Height="65"/>
</Grid.RowDefinitions>
<!-- TOP Panel-->
<Grid x:Name="TopPanel" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="0,0,0,0"
Height="{Binding RowDefinitions[0].ActualHeight, ElementName=MainGrid}"
Width="{Binding ActualWidth, ElementName=MainGrid}">
<Grid.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlDarkColorKey}}"/>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding RowDefinitions[0].ActualHeight, ElementName=MainGrid}"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="269"/>
<ColumnDefinition Width="125"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="{Binding RowDefinitions[0].ActualHeight, ElementName=MainGrid}"/>
</Grid.RowDefinitions>
<Button x:Name="PageNumberButton" Content="100" Grid.Column="0"
Background="{Binding Background, ElementName=TopPanel}"
HorizontalAlignment="Left"
Height="{Binding Height, ElementName=TopPanel}"
Width="{Binding ActualHeight, ElementName=TopPanel}" Click="PageNumberButton_Click"/>
<Label x:Name="PageTitleLabel" Content="PageTitle" Grid.Column="1"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,0,0" FontSize="16"
Width="319"
Height="{Binding Height, ElementName=TopPanel}"
BorderBrush ="DarkGray" BorderThickness="1"/>
<!--<local:TopMenu Grid.Column="2"/>-->
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Button x:Name="BtnProcess" Content="Process" Margin="1,0" VerticalAlignment="Top"
Height="{Binding ActualHeight, ElementName=TopPanel}"
Width="{Binding ActualHeight, ElementName=TopPanel}"/>
<Button x:Name="BtnMenu" Content="Menu" Margin="1,0" VerticalAlignment="Top"
Height="{Binding ActualHeight, ElementName=TopPanel}"
Width="{Binding ActualHeight, ElementName=TopPanel}"/>
<Button x:Name="BtnLogin" Content="Login" Margin="1,0" VerticalAlignment="Top"
Height="{Binding ActualHeight, ElementName=TopPanel}"
Width="{Binding ActualHeight, ElementName=TopPanel}"/>
<Button x:Name="BtnExit" Content="Exit" Margin="1,0" VerticalAlignment="Top"
Height="{Binding ActualHeight, ElementName=TopPanel}"
Width="{Binding ActualHeight, ElementName=TopPanel}" Click="BtnExit_Click"/>
</StackPanel>
<!-- Date/Time Panel-->
<Grid x:Name="DateTimePanel" VerticalAlignment="Bottom" HorizontalAlignment="Center"
Grid.Column="3"
Width="125"
Height="{Binding Height, ElementName=TopPanel}">
<Grid.Background>
<ImageBrush ImageSource="Resources/logo.bmp" Stretch="Uniform"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="19"/>
<RowDefinition Height="19"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Content=" "/>
<Label x:Name="DateLabel" Grid.Row="1" HorizontalContentAlignment="Center" FontSize="11"
Content="{Binding Mode=OneWay, Source={StaticResource date}, StringFormat=\{0:MM.dd.yy\}}" />
<Label x:Name="TimeLabel" Grid.Row="2" HorizontalContentAlignment="Center" FontSize="11"
Content="{Binding Mode=OneWay, Source={StaticResource date}, StringFormat=\{0:HH:mm:ss\}}" />
</Grid>
</Grid>
<DockPanel x:Name="MainPanel" Grid.Row="1" Grid.Column="0"
Height="{Binding RowDefinitions[1].ActualHeight, ElementName=MainGrid}"
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}}"
Background="#FFF9DCB6">
<Label Content="Main Panel" Height="462" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="32"/>
</DockPanel>
<!-- BOTTOM Panel -->
<StackPanel x:Name="BottomPanel" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,0,0"
Height="{Binding RowDefinitions[0].ActualHeight, ElementName=MainGrid}"
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}}" >
<StackPanel.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlDarkColorKey}}"/>
</StackPanel.Background>
</StackPanel>
</Grid>
</Window>
(右上のパネルに私は、日付と時刻を表示したい。自動的にこの方法でそれを更新するには、このことは可能ですか?)
(私は...唯一のXAML、現時点でコード化された何も肝炎ません)ブレンドが正しくウィンドウを示しています: アプリの実行が唯一の白い長方形です: Visual Studioは時々だけ白矩形を表示する
さらに、Windowsからフレーム枠を取り除く必要がありますが、これは既に私のリストにあります。
ありがとうございました。
'Height =" {バインディングRowDefinitions [0] .ActualHeight、ElementName = MainGrid} "や' Width = "{ActualWidth、ElementName = MainGridのバインディング}"という意味はまったく意味がありません。親グリッドは、すでに子をセルのサイズにリサイズします。 – Clemens