using System.Windows;
|
using System.Windows.Controls;
|
|
namespace WPFProject.Controls
|
{
|
/// <summary>
|
/// WinFormHolder.xaml 的交互逻辑
|
/// </summary>
|
public partial class WinFormHolder : UserControl
|
{
|
|
private HolderForm holderForm;
|
public WinFormHolder()
|
{
|
holderForm = new HolderForm();
|
InitializeComponent();
|
holderForm.TopLevel = false;
|
holderForm.Dock = System.Windows.Forms.DockStyle.Fill;
|
host.Child = holderForm;
|
}
|
|
public object Content
|
{
|
get => holderForm?.Content;
|
set => holderForm?.UpdateChild(value);
|
}
|
|
public bool MaskVisiable
|
{
|
get => GetMaskVisiable(this);
|
set => SetMaskVisiable(this, value);
|
}
|
|
public static bool GetMaskVisiable(WinFormHolder obj)
|
{
|
return (bool)obj.GetValue(MaskVisiableProperty);
|
}
|
|
public static void SetMaskVisiable(WinFormHolder obj, bool? value)
|
{
|
obj.SetValue(MaskVisiableProperty, value);
|
}
|
|
public static readonly DependencyProperty MaskVisiableProperty =
|
DependencyProperty.RegisterAttached("MaskVisiable", typeof(bool?), typeof(WinFormHolder)
|
, new PropertyMetadata(null, OnSpaceChanged));
|
|
private static void OnSpaceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
{
|
if (d is WinFormHolder obj)
|
{
|
if (e.NewValue is bool flag && flag == true)
|
{
|
obj.holderForm.ShowMask();
|
}
|
else
|
{
|
obj.holderForm.HideMask();
|
}
|
}
|
}
|
}
|
}
|