Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Textblock inside button + clickable area issue

$
0
0

Hello All, I have a button and I have put a Textblock inside it to look it like linkbutton. And I have to fix the button width... now the issue is even my text is only ten characters, I can click on the remaining space area... I want clickable area limited to text width only... also note that here I am ussing texttrimming so I have to specify width to textblock.

<Style x:Key="ActionButton" TargetType="Button">
        <Setter Property="Foreground" Value="{StaticResource brush:LinkText}" />
        <Setter Property="Width" Value="100"></Setter>
        <Setter Property="Command" Value="{Binding DataContext.SubItemClickCommand, ElementName=DataItemListBox}"></Setter>
        <Setter Property="CommandParameter" Value="{Binding}"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ControlTemplate.Resources>
                        <Style TargetType="{x:Type TextBlock}">
                            <Setter Property="Foreground" Value="{StaticResource brush:LinkText}" />
                            <Setter Property="FontSize" Value="12"></Setter>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Cursor" Value="Hand"/>
                                    <Setter Property="TextDecorations" Value="Underline"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ControlTemplate.Resources>
                    <Grid>
                       <TextBlock Text="{TemplateBinding Content}" Foreground="{StaticResource brush:LinkText}" TextTrimming="CharacterEllipsis"  MaxWidth="{TemplateBinding Width}" FontSize="12" >
                            <TextBlock.ToolTip>
                                <ToolTip Content="{Binding FieldText}" Style="{DynamicResource SearchTooltip}">
                                </ToolTip>
                            </TextBlock.ToolTip>
                        </TextBlock>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>