获取报表查看器以填充网格?

时间:2015-08-26 19:30:53

标签: c# wpf

我正在尝试使用WPF向用户呈现报告。我继续使用报告向导来创建我想要的图表。我的问题是,我似乎无法获得实际图表来填充它嵌套的Grid / WindowsFormsHost

似乎想要留在我在RDLC设计师中延伸到的任何宽度和高度。有什么办法可以在初始化时将其设置为填充其父级吗?

编辑:

继承我的XAML:

<Window x:Class="CloudMonitor.Client.UI.Start"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Start" Height="972" Width="1315"
xmlns:convert="clr-namespace:CloudMonitor.Client.Convert"
xmlns:rv="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms" >
    <Window.Resources>
    <convert:ConnectionStatusConverter x:Key="ConnectionStatusConverter"/>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height=".9*"/>
            <RowDefinition Height=".1*"/>
        </Grid.RowDefinitions>

        <Grid x:Name="ReportGrid" Grid.Row="0">
            <WindowsFormsHost >
                <rv:ReportViewer x:Name="_reportViewer"/>
            </WindowsFormsHost>
        </Grid>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button x:Name="InitializeHubButton" Grid.Column="0" Content="Init Hub" Width="50" Height="20" HorizontalAlignment="Center" Click="InitializeHubButton_OnClick"></Button>
            <Button x:Name="SendSimpleHailButton" Grid.Column="1" Content="Simple Hail" Width="90" Height="20" HorizontalAlignment="Center" Command="{Binding SendTestHail}" ></Button>
        </Grid>

        <Rectangle Fill="{Binding IsConnected, Converter={StaticResource ConnectionStatusConverter}}" Grid.Column="1" HorizontalAlignment="right" Height="20" Stroke="Black" VerticalAlignment="Bottom" Width="20"/>
    </Grid>
</Window>

2 个答案:

答案 0 :(得分:0)

您需要创建一个Usercontrol并将Report Viewer放在那里,然后将其设置为Grid。

答案 1 :(得分:0)

尝试从“窗口定义”中替换此行:

Title="Start" Height="972" Width="1315"

有了这个:

Title="Start" d:DesignHeight="972" d:DesignWidth="1315"