扩展扩展器时滚动ScrollViewer

Sta*_*rov 4 wpf scroll expander mvvm

我有一个WPF MVVM应用程序,其中ScrollViewer包含一个带有多个Expanders的用户控件

<UserControl>   
    <Expander>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                ...               
            </Grid.RowDefinitions>

            <Expander Grid.Row="0" />

            <Expander Grid.Row="1" />
            ... 

        </Grid>
    </Expander>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

我怎样才能使扩展的Expander滚动到视图中,以便它的内容可见?

Fed*_*gui 6

Expanded.Expanded在usercontrol后面的代码中处理事件,然后调用`Expander.BringIntoView()'.

注意:使用代码隐藏特定于VIEW的东西没有任何问题,因此这不会破坏MVVM,IMO.