1

I have a ListView with a GridView. Two of the GridViewColumnshave the header width less than the content defined in the DataTemplate, as shown

in the figure

The XAML is defined as follow:

<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>

and the XAML of the Xceed style is the following:

<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>

Any help is really appreciate! Thanks

ctt_it
  • 339
  • 1
  • 6
  • 22

1 Answers1

0

Solved. I substitute the StackPanel with a Grid.

<GridViewColumn Header="{Binding MinTemperatureUnitMeasure, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" 
      x:Name="MinTemperatureColumn"
      Width="{Binding IsCurrentJobTermocamera, Converter={StaticResource BoolToSizeConverter}}">
      <GridViewColumn.CellTemplate>
            <DataTemplate>
                 <Grid>
                       <Grid.ColumnDefinitions>
                             <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <xctk:DoubleUpDown
                              Grid.Column="0"
                              Margin="5"
                              Value="{Binding AdditionalData.MinTemperature, Converter={StaticResource TemperatureToTemperatureConverter}, Mode=TwoWay}"
                              Style="{DynamicResource TemperatureDoubleUpDown}"
                               Minimum="{Binding AbsoluteTemperatureMinimum, RelativeSource={RelativeSource 
                                                    Mode=FindAncestor, AncestorType=Window}}"
                               ValueChanged="OnRunDataChanged"
                               HorizontalAlignment="Stretch"/>
                    </Grid>
             </DataTemplate>
        </GridViewColumn.CellTemplate>
 </GridViewColumn>
ctt_it
  • 339
  • 1
  • 6
  • 22