我的問題是可見的圖像「wrong.png」 我已經創建了一個應該有3列,並停靠在底部的堆疊面板,以及它的內容,在這案件是3個按鈕。看着「wrong.png」,這對我來說並不好。停靠在底部的堆棧面板,並添加列定義
我已經添加了另一個圖像「desired.png」,它顯示了我想實現的目標。 感謝您提供任何幫助。
這裏是代碼:
<Window x:Class="EnerMedit.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="499.88" Width="702">
<DockPanel LastChildFill="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Content="Seavaro" Grid.Row="0" FontSize="18" />
<Label Content="Date" Grid.Row="1" />
<DatePicker Grid.Row="2" Name="datepicker" Background="Honeydew" />
<Label Content="Note:" FontWeight="ExtraBold" Grid.Row="3" Margin="0 10 0 0" />
<RadioButton Content="Meditation" Name="mediNote" Margin="50 17 0 0" Grid.Row="3" />
<RadioButton Content="Energy" Name="energyNote" Margin="150 17 0 0" Grid.Row="3" />
<RadioButton Content="Both" Name="bothNoteButton" Margin="250 17 0 0" Grid.Row="3" Checked="bothNoteButton_Checked" />
<TextBox Grid.Row="4" Background="Honeydew" />
<Separator Width="auto" Grid.Row="5" Margin="0 20 0 20" Background="GreenYellow"/>
<TextBox Grid.Row="6" MinHeight="150" TextWrapping="Wrap" Background="Honeydew" IsReadOnly="True" />
<CheckBox Content="Done" Name="doneCheck" Grid.Row="7" Margin="5 7 0 0" />
<Label Content="Akana" Grid.Column="1" Grid.Row="0" FontSize="18" Margin="10 0 0 0" />
<CheckBox Content="Check all" Grid.Column="1" Grid.Row="1" Margin="200 7 0 0" Name="IsCheckedCheckAll"
Checked="IsCheckedCheckAll_Checked" Unchecked="IsCheckedCheckAll_Checked" />
<Label Content="Excercise 1" Grid.Column="1" Grid.Row="2" FontFamily="Comic Sans MS" Margin="10 0 0 0" />
<CheckBox Name="Exc1" Grid.Column="1" Grid.Row="2" Margin="200 7 0 0" IsChecked="{Binding IsChecked, ElementName=IsCheckedCheckAll, Mode=OneWay}" />
<Label Content="Excercise 2" Grid.Column="1" Grid.Row="3" FontFamily="Comic Sans MS" Margin="10 0 0 0" />
<CheckBox Name="Exc2" Grid.Column="1" Grid.Row="3" Margin="200 7 0 0" IsChecked="{Binding IsChecked, ElementName=IsCheckedCheckAll, Mode=OneWay}" />
<Label Content="Excercise 3" Grid.Column="1" Grid.Row="4" FontFamily="Comic Sans MS" Margin="10 0 0 0" />
<CheckBox Name="Exc3" Grid.Column="1" Grid.Row="4" Margin="200 7 0 0" IsChecked="{Binding IsChecked, ElementName=IsCheckedCheckAll, Mode=OneWay}" />
<Label Content="Excercise 4" Grid.Column="1" Grid.Row="5" FontFamily="Comic Sans MS" Margin="10 0 0 0" />
<CheckBox Name="Exc4" Grid.Column="1" Grid.Row="5" Margin="200 7 0 0" IsChecked="{Binding IsChecked, ElementName=IsCheckedCheckAll, Mode=OneWay}" />
<Label Content="Excercise 5" Grid.Column="1" Grid.Row="6" FontFamily="Comic Sans MS" Margin="10 0 0 0" />
<CheckBox Name="Exc5" Grid.Column="1" Grid.Row="6" Margin="200 07 0 0" IsChecked="{Binding IsChecked, ElementName=IsCheckedCheckAll, Mode=OneWay}" />
</Grid>
<StackPanel VerticalAlignment="Bottom">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Content="Add" Name="SubmitButton" Grid.Column="0" Height="23" IsEnabled="{Binding ElementName=doneCheck, Path=IsChecked}" />
<Button Content="Labaci recardo" Name="GetMedButton" Grid.Column="1" Grid.Row="9" />
<Button Content="Supa recardo" Name="GetEnegButton" Grid.Column="2" />
</Grid>
</StackPanel>
</DockPanel>
嘗試將您的'StackPanel'放在更高一層。 – AgentFire 2014-09-21 11:01:06
在我將它移出之前,我曾嘗試過。按鈕仍然浮動在頂部,但是這次在右側,並且將只有兩列,因爲在該級別上已經有另一個列定義了。 – user1960836 2014-09-21 11:06:54