2
有沒有更好的方法來對齊列?當文字改變時,3列和4列在整個地方移動。我已經嘗試設置寬度*和自動,但似乎沒有工作。列表框中的列對齊
<ListBox Height="Auto" BorderThickness="0" MouseDoubleClick="OnMouseDoubleClick" ItemsSource="{Binding Path=Results}" SelectedItem="{Binding Path=Entry, Mode=TwoWay}" AlternationCount="2">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="150"></ColumnDefinition>
<ColumnDefinition MinWidth="150"></ColumnDefinition>
<ColumnDefinition MinWidth="150"></ColumnDefinition>
<ColumnDefinition MinWidth="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" FontFamily="Sagoe UI" FontSize="14"
Text="{Binding FullName}" Padding="2" />
<TextBlock Grid.Column="1" FontFamily="Sagoe UI" FontSize="14"
Text="{Binding Company}" Padding="2" />
<TextBlock Grid.Column="2" FontFamily="Sagoe UI" FontSize="14"
Text="{Binding BusinessPhone}" Padding="2" />
<TextBlock Grid.Column="3" FontFamily="Sagoe UI" FontSize="14"
Text="{Binding EmailAddress}" Padding="2" >
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
好像你正試圖用'GridView'創建你自己的'ListView'。看看這個例子,它可能是你需要的:http://www.c-sharpcorner.com/uploadfile/mahesh/gridview-in-wpf/ – 2kay