这个窗口布局上,我使用了Grid控件
我把这个窗口首先划分成三行三列的一个Grid。如上图我对这个窗体的拆分。
最上面的显示多少条目、下拉列表框和刷新按钮,被放在第一行,跨三列;未发布的调查表列表框被放在第二行,第一列;支持来回拖动的GridSplitter被我放在了第二列,第二行;ListView则被我放在了第二行,第三列;最下面的确定,取消按钮被我放在了第三行,跨了三个列。
上述界面效果的XAML文件如下:
<Windowxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"x:Class="HongjunGuo.SurveySystem.Client.QuestionnaireList"Title="调查列表" Height="300" Width="500"><Grid ><Grid.ColumnDefinitions><ColumnDefinition Width="150"/><ColumnDefinition Width="5" /><ColumnDefinition Width="*"/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="35"/><RowDefinition Height="*"/><RowDefinition Height="35"/></Grid.RowDefinitions><DockPanel Height="30" Name="dockPanel2" Grid.ColumnSpan="3" Grid.Row="0"><Label>显示多少条目:</Label><ComboBox Height="21" Name="comboBox1" Width="120" ><ComboBoxItem IsSelected="True" >5</ComboBoxItem><ComboBoxItem>10</ComboBoxItem><ComboBoxItem>20</ComboBoxItem><ComboBoxItem>50</ComboBoxItem></ComboBox><Button Height="23" Name="button1" Width="75">刷新</Button></DockPanel><ListBox IsSynchronizedWithCurrentItem="True" Name="lb_Type" Width="Auto" Grid.Column="0" Grid.Row="1" ><ListBoxItem Name="lbi_Draft" ToolTip="最近使用的,并且没有被发布的调查表"Content="本地未发布的调查表草稿" Height="50" IsSelected="True"/><ListBoxItem Name="lbi_Release" Content="本地最近发布的调查表" Height="50"/><ListBoxItem Name="lbi_Seatch" Content="服务器上的调查列表" Height="50"/></ListBox><GridSplitter Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left"Name="gridSplitter1" Width="10" /><ListView Name="lv_Data" IsSynchronizedWithCurrentItem="True"Grid.Column="3" Grid.Row="1"><ListView.View><GridView><GridViewColumn Header="编号"></GridViewColumn><GridViewColumn Header="标题"></GridViewColumn><GridViewColumn Header="创建时间"></GridViewColumn></GridView></ListView.View></ListView><DockPanel Height="30" Name="dockPanel4" Grid.ColumnSpan="3" Grid.Row="2"><Button Height="23" Name="btn_OK" Width="75" IsDefault="True"Click="btn_OK_Click">确 定</Button><Button Height="23" Name="btn_Cancel" Width="75"IsCancel="True">取 消</Button></DockPanel></Grid></Window>
使用Grid布局控件的时候,一些知识点如下:
(编辑:aniston)
·2024年12月目录 ·2024年11月目录 ·2024年10月目录 ·2024年9月目录 ·2024年8月目录 ·2024年7月目录 ·2024年6月目录 ·2024年5月目录 ·2024年4月目录 ·2024年3月目录 ·2024年2月目录 ·2024年1月目录 ·2023年12月目录 ·2023年11月目录