我有ListView
一个GridView
。其中两个的GridViewColumns
标题宽度小于 中定义的内容DataTemplate
,如图所示
XAML 定义如下:
<GridViewColumn Header="{lex:Loc Lang:minTemperature}" x:Name="MinTemperatureColumn"
Width="{Binding IsVisible, Converter={StaticResource BoolToSizeConverter}}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<xctk:DoubleUpDown
Value="{Binding AdditionalData.MinTemperature, Converter={StaticResource TemperatureToTemperatureConverter}, Mode=TwoWay}"
Style="{DynamicResource TemperatureDoubleUpDown}"
Minimum="{Binding AbsoluteTemperatureMinimum, RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType=Window}}"
ValueChanged="OnRunDataChanged" />
<TextBlock
Text="{Binding TemperatureUnitMeasure, RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType=Window}}"
Margin="3"
VerticalAlignment="Center"
Foreground="{DynamicResource StandardForegroundColor}" />
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Xceed 风格的 XAML 如下:
<Style x:Key="TemperatureDoubleUpDown" TargetType="{x:Type xctk:DoubleUpDown}"
BasedOn="{StaticResource {x:Type xctk:DoubleUpDown}}">
<Setter Property="FontSize" Value="18" />
<Setter Property="Width" Value="Auto" />
<Setter Property="Increment" Value="1" />
<Setter Property="FormatString" Value="N0" />
</Style>
任何帮助都非常感谢!谢谢