locked
ChangePropertyAction when using Interactions' DataTriggers in Silverlight RRS feed

  • Question

  • Hi there,

    I cannot seem to get working Interactions.DataTriggers with ChangePropertyAction in Silverlight 4 - I cannot set a property for my control at all.

    In my page, I have a button that gets disabled on a click event and when it gets disabled, I just need to resize it vertically using ChangePropetyAction. Here's my XAML:

    <Grid x:Name="LayoutRoot">
        <Button Name="FirstButton"
            Margin="10"
            Content="Click me"
            Click="Button_Click"
            Height="100"
            VerticalAlignment="Top">
          <Button.Resources>
            <ei:DataTrigger Binding="{Binding Path=IsEnabled, ElementName=FirstButton, Converter={StaticResource mockConverter}}"
                    Value="False"
                    x:Key="trigger">
              <ei:ChangePropertyAction PropertyName="Height"
                           TargetObject="{Binding ElementName=FirstButton}"
                           Value="200">
              </ei:ChangePropertyAction>
            </ei:DataTrigger>
          </Button.Resources>
        </Button>
      </Grid>
    

    in the code behind file, I handle the click event and just set the button's IsEnabled property to false:

    private void Button_Click(object sender, RoutedEventArgs e)
        {
          FirstButton.IsEnabled = false;
        }
    

    Now, I also have a simple converter (mockConverter) that just returns the value received as parameter to make sure that the ei:DataTrigger binding is hooked up correctly...and it is (was able to set a breakpoint in the Convert method and in runtime after clicking the button, it got me there correctly). The problem seems to be that ChangePropertyAction doesn't set the Height to 200 when the button gets disabled.

    Is this an issue or am I doing something wrong?

    Thanks a lot.

    Wednesday, September 1, 2010 8:31 AM

All replies

  • I realize this doesn't answer your actual question, but you could just change the height in the click handler. I'm not quite sure why what you have above doesn't work properly.

     

    Wednesday, September 1, 2010 2:26 PM
    Moderator