WPF-Caliburn micro中的ScrollViewer

问题描述 投票:1回答:1

我无法使用Caliburn Micro MVVM时使WPF中的ScrollViewer起作用! https://github.com/moon1234moon/Factures

这是我的XML代码:

<ScrollViewer VerticalScrollBarVisibility="Visible"
                  HorizontalScrollBarVisibility="Visible">
        <Grid HorizontalAlignment="Left" VerticalAlignment="Top"
              MaxHeight="900"
              MaxWidth="900"
              >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="20" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="20" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="20" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="20" />
            </Grid.RowDefinitions>

            <!-- Deleted because they are quite a lot -->

            <ContentControl Grid.Column="3" Grid.Row="1" Grid.RowSpan="5" 
                        x:Name="ActiveItem"
                        Margin="30, 150, 30, 30"
                        />
        </Grid>
    </ScrollViewer>

当然,我尝试使滚动启用IsEnabled = true,并向其中添加了VerticalAlignmentHorizentalAlignment,但似乎都不起作用!..

请帮助! PS:对我来说,最重要的部分是能够水平滚动以查看ContentControl的内容

这是结果:Image shows scroll to be not enabled

c# wpf mvvm caliburn.micro
1个回答
0
投票

1)从您是用户控制的视图中推迟命令MaxHeight和MaxWidth

2)放下同一视图的scrollviewer,并在主窗口(我想是shellview)中定义scrollviewer。主窗口包含所有用户控件

3)一切都会好的

© www.soinside.com 2019 - 2024. All rights reserved.