1

我有一个带有多个扩展器的 WPF 应用程序

<ScrollViewer>
    <StackPanel>
        <Expander Header="OuterExpander1" Expanded="ExpanderExpanded">
            <StackPanel>
                <Expander Header="InnerExpander1" Expanded="ExpanderExpanded"/>
                <Expander Header="InnerExpander2" Expanded="ExpanderExpanded"/>
            </StackPanel>
        </Expander>
        <Expander Header="OuterExpander2" Expanded="ExpanderExpanded">
            <StackPanel>
                <Expander Header="InnerExpander3" Expanded="ExpanderExpanded"/>
                <Expander Header="InnerExpander4" Expanded="ExpanderExpanded"/>
            </StackPanel>
        </Expander>
    </StackPanel>
</ScrollViewer>

private void ExpanderExpanded(object sender, System.Windows.RoutedEventArgs e)
{
    (sender as Expander).BringIntoView(new Rect(0, 0, 0, 1000));
}

但是 BringIntoView 方法不适用于内部扩展器,我该如何解决这个问题?

4

1 回答 1

0

尝试为扩展器设置 ax:Name。它似乎为我解决了问题!

于 2012-11-13T22:51:24.740 回答