Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1485
Preserve "default" row height in a control template
posted

Hi,

I'm using the following control template to display an icon on the left of some text when necessary.  I just noticed that when I use it, the row height is a few pixels short of what it is by default, so characters with descenders such as "y" are partially truncated (the lower part of the "y" is not displayed, for example.)  What do I need to do to this control template to resolve this?

 

                <Style x:Key="WarningIconCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                                <StackPanel Orientation="Horizontal">
                                    <!-- Give the left edge of the cell a vertical line. -->
                                    <Border
                                        BorderBrush="#FFEEEEEE"
                                        BorderThickness="1,0,0,0"
                                        />
                                    <Image
                                        x:Name="WarningIcon"
                                        Source="Images\icons\warning_16x16.png"
                                        Stretch="Fill"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Width="16"
                                        ToolTipService.ShowDuration="60000"
                                        ToolTipOpening="WarningIcon_ToolTipOpening"
                                        Height="16">
                                        <Image.ToolTip>
                                            <StackPanel
                                                Orientation="Horizontal">
                                                <Image
                                                   Source="Images\icons\warning_48x48.png"
                                                   Stretch="Fill"
                                                   HorizontalAlignment="Center"
                                                   VerticalAlignment="Center"
                                                   Width="48"
                                                    Height="48"
                                                    />
                                                <TextBlock
                                                    Margin="5,5,5,5"
                                                    MaxWidth="300"
                                                    TextWrapping="Wrap"
                                                    Text="{Binding Path=DataItem.WarningText}"/>
                                            </StackPanel>
                                        </Image.ToolTip>
                                    </Image>
                                    <Label
                                        x:Name="PhraseField"
                                        Content="{Binding Path=DataItem.Phrase}"
                                        />
                                </StackPanel>
                                <!-- Hide the warning icon if there is no warning for the phrase -->
                                <ControlTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Path=DataItem.HasWarning}" Value="False">
                                        <Setter TargetName="WarningIcon" Property="Visibility" Value="Collapsed" />
                                    </DataTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

Thanks,
Michel

Parents
No Data
Reply
  • 1485
    Verified Answer
    posted

    D'OH!  Never mind, I had done this before, just forgotten all about it.  I added this to the Label's property:

                                            Width="{TemplateBinding Width}"
                                            Height="{TemplateBinding Height}"
                                            Margin="0,0,0,0"
                                            Padding="0,0,0,0"

Children
No Data