我创建了一个带有elementhost的表单来保存我的usercontrol(xaml)。单击一个按钮时,一切都正常工作,除了我的usercontrol(xaml)也是透明的,我不希望它。任何人都可以对这个问题有所了解吗?
frmShow.Designer.cs
private void InitializeComponent()
{
this.elementHost1 = new System.Windows.Forms.Integration.ElementHost();
this.loadingImage1 = new LoadingImage.WPF.Views.LoadingImage();
this.SuspendLayout();
//
// elementHost1
//
this.elementHost1.Dock = System.Windows.Forms.DockStyle.Fill;
this.elementHost1.Location = new System.Drawing.Point(0, 0);
this.elementHost1.Name = "elementHost1";
this.elementHost1.Size = new System.Drawing.Size(284, 262);
this.elementHost1.TabIndex = 0;
this.elementHost1.Text = "elementHost1";
this.elementHost1.Child = this.loadingImage1;
//
// frmShow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.elementHost1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "frmShow";
this.Opacity = 0.5D;
this.Text = "frmShow";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ResumeLayout(false);
}
LoadingImage.xaml
<UserControl
x:Class="Test.WPF.Views.LoadingImage"
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"
Height="100"
Width="100">
<Grid>
<Rectangle
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Opacity="0.6"
Fill="Gray" />
<Border
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="Red"
BorderThickness="3"
Background="Green"
CornerRadius="8">
<TextBlock
HorizontalAlignment="Center"
Margin="20,10"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="18.667"
Foreground="White"
TextWrapping="Wrap"
Text="Tesing" />
</Border>
</Grid>
</UserControl>