WindowsFormsHost 不适用于 WPF 用户控件
WindowsFormHost not working for WPF user control
我想使用来自 WPF 用户控件的 windowsformhost 通过 reportviewer 显示报告,我在调试时没有发现错误和警告,但是当我 运行 程序 windowsformhost 似乎隐。当我将用户控件更改为 window
时,相同的代码工作正常(windowsformhost 可见)
有什么想法吗?这里有什么问题吗?
<UserControl x:Class="myProj.UserControls.Reportrs.ucSalesReport"
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"
mc:Ignorable="d"
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:RV="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"
d:DesignHeight="768" FontFamily="Open Sans"
d:DesignWidth="1024" Background="#e3e7e8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="7"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="7"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="7"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="7"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="7"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="7"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="7"></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Column="1" Content="From Date" VerticalAlignment="Center"></Label>
<Label Grid.Column="3" Content="To Date" VerticalAlignment="Center"></Label>
<DatePicker Style="{StaticResource DatePickerStyleFromNew}" Name="dpFrom" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="30"></DatePicker>
<DatePicker Style="{StaticResource DatePickerStyleFromNew}" Name="dpTo" Grid.Column="3" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="30" Width="auto"></DatePicker>
<Button Name="btnReport" Click="btnReport_Click" Margin="5" Style="{StaticResource styleNormalYellowButton}" Content="REPORT" Grid.Row="1" Grid.Column="7"></Button>
<WindowsFormsHost x:Name="winFormHost" Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="7" >
<WindowsFormsHost.Child>
<RV:ReportViewer x:Name="SalesReportViewer" BorderStyle="FixedSingle" ProcessingMode="Local"></RV:ReportViewer>
</WindowsFormsHost.Child>
</WindowsFormsHost>
</Grid>
为 Window 设置 AllowsTransparency="False"
已解决此问题。
我想使用来自 WPF 用户控件的 windowsformhost 通过 reportviewer 显示报告,我在调试时没有发现错误和警告,但是当我 运行 程序 windowsformhost 似乎隐。当我将用户控件更改为 window
时,相同的代码工作正常(windowsformhost 可见)有什么想法吗?这里有什么问题吗?
<UserControl x:Class="myProj.UserControls.Reportrs.ucSalesReport"
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"
mc:Ignorable="d"
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:RV="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"
d:DesignHeight="768" FontFamily="Open Sans"
d:DesignWidth="1024" Background="#e3e7e8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="7"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="7"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="7"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="7"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="7"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="7"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="7"></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Column="1" Content="From Date" VerticalAlignment="Center"></Label>
<Label Grid.Column="3" Content="To Date" VerticalAlignment="Center"></Label>
<DatePicker Style="{StaticResource DatePickerStyleFromNew}" Name="dpFrom" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="30"></DatePicker>
<DatePicker Style="{StaticResource DatePickerStyleFromNew}" Name="dpTo" Grid.Column="3" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="30" Width="auto"></DatePicker>
<Button Name="btnReport" Click="btnReport_Click" Margin="5" Style="{StaticResource styleNormalYellowButton}" Content="REPORT" Grid.Row="1" Grid.Column="7"></Button>
<WindowsFormsHost x:Name="winFormHost" Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="7" >
<WindowsFormsHost.Child>
<RV:ReportViewer x:Name="SalesReportViewer" BorderStyle="FixedSingle" ProcessingMode="Local"></RV:ReportViewer>
</WindowsFormsHost.Child>
</WindowsFormsHost>
</Grid>
为 Window 设置 AllowsTransparency="False"
已解决此问题。