Reputation: 11
I want two buttons as an overlay in Listview. So when mouseover on listviewitem the buttons should come on the right side of the listviewitem. and the listviewitem shoudl be sent as commandparameter on button click.
I am able to put the buttons in last column of the listview and it works fine. But if the first column name is too big than last column is not seen on MouseOver.
Upvotes: 1
Views: 957
Reputation: 27328
You have to edit ListViewItem template. The template contains GridViewRowPresenter and you need to add your overlay on top of the GridViewRowPresenter.
<Style x:Key="{x:Type ListViewItem}" TargetType="ListViewItem">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border Name="Border" Padding="2" SnapsToDevicePixels="true" Background="Transparent">
<Grid>
<GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<!-- place your overlay here -->
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Border"
Property="Background" Value="{StaticResource SelectedBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground"
Value="{StaticResource DisabledForegroundBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Upvotes: 1