TreeView展开所选项目并从其他元素触发器展开

时间:2019-10-24 12:44:29

标签: wpf triggers boolean treeview eventtrigger

    <Rectangle Name="rect" Fill="Red" HorizontalAlignment="Stretch" Height="50">
                <Rectangle.Triggers>
                    <EventTrigger RoutedEvent="Rectangle.MouseDown">

                            <BeginStoryboard>
                                <Storyboard>
                                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="TreeView" Storyboard.TargetProperty="(SelectedItem).(IsExpanded)">
                                        <DiscreteBooleanKeyFrame KeyTime="00:00:1" Value="True" ></DiscreteBooleanKeyFrame>
                                    </BooleanAnimationUsingKeyFrames>
                                </Storyboard>
                        </BeginStoryboard>

                    </EventTrigger>

                </Rectangle.Triggers>
            </Rectangle>

            <TreeView  Name="TreeView">
                <TreeViewItem>hello</TreeViewItem>
                <TreeViewItem>world</TreeViewItem>
            </TreeView>

这是我尝试扩展单击矩形的方式,给出有关属性名称错误的错误。绝对是我不知道的属性命名约定。请帮我找出正确的命名约定,以及代码中是否还有其他问题。

0 个答案:

没有答案