locked
styletrigger using MVVM pattern in Silverlight application RRS feed

  • Question

  • I need to implement a storyboard which make multiple controls visible while mouse enter inside container grid. As we are using MVVM pattern in Silverlight application,  ideally the code is written in viewmodel only but due to unavailability of styletrigger in Silverlight.

     

    Following is the code by which same functionally can be obtained in WPF.

    <Page.Resources>
        <Style TargetType="StackPanel">
          <Style.Triggers>
            <EventTrigger RoutedEvent="StackPanel.MouseEnter">
              <BeginStoryboard>
                <Storyboard>
                  <DoubleAnimation
                    Storyboard.TargetProperty="(Button.Opacity)"
                    From="0.0" To="1.0" Duration="0:0:3"/>
                </Storyboard>
              </BeginStoryboard>
            </EventTrigger>
          </Style.Triggers>
        </Style>  
      </Page.Resources>

     

    As per this link http://forums.silverlight.net/forums/t/9130.aspx   I have implemented the work around which is not as per MVVM.

    Please let me know if there is any alternative to implement the same in Silverlight using MVVM.

    Thank you in advance.

    Friday, December 10, 2010 9:25 AM

Answers