WPF - Setting usercontrol width using triggers and mouseenter event

Posted by BigBadJock on Stack Overflow See other posts from Stack Overflow or by BigBadJock
Published on 2010-04-30T14:52:48Z Indexed on 2010/05/05 10:38 UTC
Read the original article Hit count: 571

Filed under:
|
|
|

I have a wrap panel full of usercontrols. When I hover the mouse over a usercontrol I want it to expand to show more details.

Some stripped down sample code:

<UserControl x:Class="WPFTestBed.UserControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <UserControl.Resources>

    </UserControl.Resources>
    <UserControl.Triggers>
        <EventTrigger RoutedEvent="Mouse.MouseEnter">
            <EventTrigger.Actions>
                <Setter TargetName="WPFTestBed.UserControl1" Property="Control.Width" Value="200"/>
            </EventTrigger.Actions>
        </EventTrigger>
    </UserControl.Triggers>
    <Grid Height="95" Width="123">
        <Button Height="23" HorizontalAlignment="Left" Margin="17,30,0,0" Name="button1" VerticalAlignment="Top" Width="75">Button</Button>
    </Grid>
</UserControl>

I would appreciate it if someone could point out where I'm going wrong, and set me down the correct path.

Ideally, I want the usercontrol to delay for x seconds when there is a mouseover, before expanding and showing the extra details.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about usercontrol