【问题标题】:ScrollViewer in WPF-Caliburn microWPF-Caliburn micro 中的 ScrollViewer
【发布时间】:2019-10-16 15:56:41
【问题描述】:

在使用 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

【问题讨论】:

  • 您不想在 Grid 中使用 Scrollviewer?
  • 根据stackoverflow.com/questions/22756920/…这是正确的做法。
  • 是用户控件还是窗口?
  • @Frenchy 它是用户控件
  • 我跟着你我是@TravisN1213

标签: c# wpf mvvm caliburn.micro


【解决方案1】:

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

2) 推迟同一视图的滚动查看器并在主窗口中定义滚动查看器(我想是 shellview)。主窗口内容所有用户控件

3)一切都会好的

【讨论】:

  • 我也试过了,但是滚动条只会消失。
猜你喜欢
  • 2019-02-06
  • 1970-01-01
  • 2018-07-29
  • 1970-01-01
  • 1970-01-01
  • 2020-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多