views:

20

answers:

1

Consider following DataTemplate in any List Control:

<DataTemplate>
    <TextBlock Text="{Binding}" />
</DataTemplate>

and following animations:

<Window.Resources>
    <Storyboard x:Key="animExpand">
        <DoubleAnimation Storyboard.TargetProperty="Width" To="400" Duration="0:0:1" />
        <DoubleAnimation Storyboard.TargetProperty="Height" To="400" Duration="0:0:1" />
    </Storyboard>
    <Storyboard x:Key="animCollapse">
        <DoubleAnimation Storyboard.TargetProperty="Width" To="0" Duration="0:0:1" />
        <DoubleAnimation Storyboard.TargetProperty="Height" To="0" Duration="0:0:1" />
    </Storyboard>
</Window.Resources>

Now we want: when any of TextBlocks get clicked, "animExpand" apply to it and all other TextBlock have a "animCollapse".

First part is straightforward (a Trigger would do it) but the question is how to make other elements take part in this scenario?

+1  A: 

I think I would put an boolean property (IsExpanded or something) in my model and then create a datatrigger to do the animations based on that value. When a mousedown occurs on a particular item, you'd have to write the logic to updates that boolean in the other objects in the list.

mdm20