在使用 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,并向其中添加了VerticalAlignment和HorizentalAlignment,但似乎都不起作用!
请帮忙! PS:对我来说,最重要的部分是能够水平滚动以查看ContentControl 的内容
结果如下:
Image shows scroll to be not enabled
最佳答案
1)从用户控件的 View 中推迟命令MaxHeight和MaxWidth
2)推迟相同 View 的scrollviewer,并在主窗口(我想是shellview)中定义scrollviewer。主窗口包含所有用户控件
3)一切都会好的
关于c# - WPF-Caliburn Micro中的ScrollViewer,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58417363/