我有以下模板:
<DataTemplate x:Key="ListViewItemTemplate">
<Grid x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Margin="5"
VerticalAlignment="Center"
FontSize="18"
Foreground="Black"
Text="{Binding Text}"
TextWrapping="WrapWholeWords" />
<my:CustomControl Grid.Column="1"
ActualValue="{Binding Val, Mode=TwoWay}" />
<ComboBox x:Name="cboxPicker"
Grid.Column="2"
Width="70"
MaxWidth="70"
MinWidth="70"
Margin="3"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ItemsSource="{StaticResource dataSource}"
SelectedIndex="{Binding Val, Mode=TwoWay}" />
<Border Grid.Row="1"
Grid.ColumnSpan="3"
BorderBrush="Gray"
BorderThickness="1" />
</Grid>
</DataTemplate>
如果我添加了Width
,MinWidth
或MaxWidth
属性,它会将ComboBox切成两半。
如果我没有设置任何一个,那么ComboBox的宽度 大约在100-110 ,它太大了。
如何将其设置为合适且准确的尺寸?