Hi,
I have Listboxitem template as below, in that template i have button which is not visible, this button i wanted to make visible on mouse over of Listboxitem, i could do that but the problem is the button is visible as long as i am on the text of Listboxboxitem , when i try to go to button , then it becomes hidden again. i think i making something wrong in trigger .
<Style x:Key="ListBoxStyle" TargetType="{x:Type ListBox}"><Setter Property="ItemContainerStyle"><Setter.Value><Style TargetType="ListBoxItem"><Style.Resources><SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red"/></Style.Resources><Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter><Setter Property="Grid.IsSharedSizeScope" Value="True"/><Setter Property="Width" Value="{Binding Path=Width,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox}}}"></Setter><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="ListBoxItem"><Grid Width="{TemplateBinding Width}" x:Name="grd" Background="{DynamicResource ExpanderSubItemsBrush}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"><Grid.ColumnDefinitions><ColumnDefinition SharedSizeGroup="Content"/><ColumnDefinition Width="20*"/></Grid.ColumnDefinitions><ContentPresenter x:Name="CP" TextElement.FontSize="13px" Grid.Column="0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="2,0,0,0" ContextMenu="{StaticResource HeaderContextMenu}" ContentTemplate="{TemplateBinding ContentTemplate}"/><Button Style="{StaticResource btnExtra}" HorizontalAlignment="Right" VerticalContentAlignment="Top" Grid.Column="1" Height="17" Visibility="Hidden" x:Name="btn"/></Grid><ControlTemplate.Triggers><Trigger Property="IsSelected" Value="True"><Setter TargetName="CP" Property="TextElement.Foreground" Value="{DynamicResource SelectedBackgroundColor}"></Setter><Setter TargetName="CP" Property="TextElement.FontWeight" Value="SemiBold"></Setter></Trigger><!--<Trigger Property="IsMouseOver" Value="True"><Setter TargetName="CP" Property="TextElement.Foreground" Value="{DynamicResource SelectedBackgroundColor}"></Setter><Setter TargetName="btn" Property="Visibility" Value="Visible"></Setter></Trigger>--><Trigger Property="IsMouseOver" Value="True"><Setter TargetName="CP" Property="TextElement.Foreground" Value="{DynamicResource SelectedBackgroundColor}"></Setter><Setter TargetName="btn" Property="Visibility" Value="Visible"></Setter></Trigger><Trigger SourceName="grd" Property="IsMouseOver" Value="True"><Setter TargetName="CP" Property="TextElement.Foreground" Value="{DynamicResource SelectedBackgroundColor}"></Setter><Setter TargetName="btn" Property="Visibility" Value="Visible"></Setter></Trigger><Trigger SourceName="grd" Property="IsMouseDirectlyOver" Value="True"><Setter TargetName="CP" Property="TextElement.Foreground" Value="{DynamicResource SelectedBackgroundColor}"></Setter><Setter TargetName="btn" Property="Visibility" Value="Visible"></Setter></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter><Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/><Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"></Setter></Style></Setter.Value></Setter><Setter Property="Background" Value="{DynamicResource ExpanderSubItemBrush}"><!--<Setter.Value><LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5"><GradientStop Color="#FF416378" Offset="0.013"/><GradientStop Color="#FF223E4A" Offset="1"/></LinearGradientBrush></Setter.Value>--></Setter><Setter Property="FontWeight" Value="Normal"/><Setter Property="BorderBrush" Value="{x:Null}"></Setter><Setter Property="Foreground" Value="{DynamicResource ExpanderForeground}"></Setter><Setter Property="Width" Value="{Binding Path=Width,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Expander}}}"></Setter><Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter><Setter Property="SelectionMode" Value="Extended"></Setter><Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/></Style>
Sincerely, dhampall Please remember to mark the replies as answers if they help and unmark them if they provide no help.