为什么未显示数据网格?

时间:2019-03-25 12:24:20

标签: wpf

我有一个带按钮的主窗口,该按钮打开另一个具有用户控件的窗口,此用户控件具有一个数据网格。代码是这样的:

主窗口:按钮的代码:

dlgImprimirControlUsuarioView miView = new dlgImprimirControlUsuarioView();
miView.Show();

第二个窗口中的代码(位于代码后):

 public partial class dlgImprimirControlUsuarioView : Window
{
    public dlgImprimirControlUsuarioView()
    {
        InitializeComponent();

        UserControlView miView = new UserControlView();
        this.ccControlUsuario = miView;
    }
}

第二个窗口的AXML:

<Window x:Class="WpfObtenerTamañoControles.dlgImprimirControlUsuarioView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfObtenerTamañoControles"
        mc:Ignorable="d"
        Title="dlgImprimirControlUsuario" Height="200" Width="300">
    <Grid>
        <ScrollViewer Name="svControlUsuario" HorizontalAlignment="Left" Height="200" Width="300" Margin="0,0,0,0" VerticalAlignment="Top" >
            <ContentControl Name="ccControlUsuario" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top"/>
        </ScrollViewer>
    </Grid>
</Window>

第二个窗口使用的用户控件的AXML:

<UserControl x:Class="WpfObtenerTamañoControles.UserControlView"
             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:local="clr-namespace:WpfObtenerTamañoControles"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>

        <ScrollViewer Name="svDatagrid" HorizontalAlignment="Left" Height="32" Margin="0,0,0,0" VerticalAlignment="Top" Width="300">
            <DataGrid Name="dgDatagrid" HorizontalAlignment="Left" Height="120" Margin="0,0,0,0" VerticalAlignment="Top" Width="Auto">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Contador" Binding="{Binding}" Width="2.5cm"/>
                </DataGrid.Columns>
            </DataGrid>
        </ScrollViewer>
    </Grid>
</UserControl>

我可以看到第二个窗口的滚动查看器的垂直滚动条,但是看不到此滚动查看器的内容。但是我看不到问题。

谢谢。

0 个答案:

没有答案