UserControl中的C#WPF ScrollViewer不起作用

时间:2020-02-09 04:46:06

标签: c# wpf wpf-controls

我需要有关ScollerViewer的帮助。这是我的代码:

<UserControl x:Class="ConfigUI.Views.ProfileListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:local="clr-namespace:ConfigUI.Views"
             mc:Ignorable="d" 
             HorizontalAlignment="Center" VerticalAlignment="Top" 
             d:DesignHeight="700" d:DesignWidth="960">
    <Grid Margin="20" Height="500"
          ScrollViewer.CanContentScroll="True"
          ScrollViewer.VerticalScrollBarVisibility="Visible">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

       <Border ...
       /Border>

       <Border ...  /Border>

       <Border ... /Border>

   </Grid>
</UserControl>

我想要的是在显示该控件并且用户可以滚动以查看内容时显示一个ScrollBar。

但是现在滚动条不会显示...

有人可以帮忙吗?谢谢。

1 个答案:

答案 0 :(得分:1)

您不能直接在SET adate = (SELECT groomerDate FROM groomer_calendar WHERE groomerDate = dateStart AND groomerID = in_groomerID); 上拥有ScrollViewer

尝试这种结构

Grid