0
我想有一些這樣的輸出,其中column1的寬度是相同的每行。使用Grid.ColumnDefinitions width =「*」,但確保每列是相同的寬度
// [year color make model] [ - liC# - state] //want column1 size to match for both rows
// [year color make model] [ - liC# - state] //want column1 size to match for both rows
我想要的寬度被定義爲*,因爲我不知道事先的字體大小,所以我希望它大小的內容。
這是我嘗試過,但沒有奏效,row1.column1大小比row2.column1不同
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<TextBlock Text="{Binding Path=VehicleYear}" Foreground="Blue" Margin="0,0,5,0" />
<TextBlock Text="{Binding Path=ColorExteriorID, Converter={BLL:CodeMarkupExtension}}" Foreground="Blue" Margin="0,0,5,0" />
<TextBlock Text="{Binding Path=MakeID, Converter={BLL:CodeMarkupExtension}}" Foreground="Blue" Margin="0,0,5,0" />
<TextBlock Text="{Binding Path=Model}" Foreground="Blue" Margin="0,0,5,0" />
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock Text="-" Foreground="Blue" Margin="0,0,5,0" />
<TextBlock Text="{Binding Path=PlateNumber}" Foreground="Blue" Margin="0,0,5,0"/>
<TextBlock Text="-" Foreground="Blue" Margin="0,0,5,0" />
<TextBlock Text="{Binding Path=StateID, Converter={BLL:CodeMarkupExtension}}" Foreground="Blue" Margin="0,0,5,0" />
</StackPanel>
</Grid>
你只有1行。無論發生什麼事情都取決於StackPanels。 –