Anyway stoyo, all what you need is create a new user control.
And paste this code inside the new user control:
You cna create ndoe with thsi, and same, but when try load, you can see the problem.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using System.Windows.Interop;
using MindFusion.Diagramming.Wpf;
using System.Xml;
namespace window6
{
public partial class BensOnScreenKeyboard : UserControl, ISerializable, ICloneable
{
[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
[DllImport("user32.dll", SetLastError = true)]
public static extern UInt32 GetWindowLong(IntPtr hWnd, int nIndex);
/// <summary>
/// Get or set this controls parent window
/// </summary>
private Window parentWindow;
/// <summary>
/// Get or set this controls element to focus on
/// </summary>
private IInputElement focusedInputElement;
/// <summary>
/// Create a new BensOnScreenKeyboard
/// </summary>
/// <param name="parent">The parent window that calls this control</param>
public BensOnScreenKeyboard(Window parent)
{
// set parent
this.parentWindow = parent;
// setup this control
this.setupKeyboardControl();
}
/// <summary>
/// Create a new SingerOnScreenKeyboard
/// </summary>
/// <param name="parent">A specified element to hold this controls focus</param>
public BensOnScreenKeyboard(IInputElement elementToFocusOn)
{
// set focus
this.focusedInputElement = elementToFocusOn;
// setup this control
this.setupKeyboardControl();
}
/// <summary>
/// Setup the keyboard control
/// </summary>
private void setupKeyboardControl()
{
InitializeComponent();
DataContext = this;
}
public object Clone()
{
var clone = new BensOnScreenKeyboard(this);
clone.OpacityGlobal = this.OpacityGlobal;
return clone;
}
static public DependencyProperty OpacityGlobalProperty = DependencyProperty.Register("OpacityGlobal", typeof(Double), typeof(BensOnScreenKeyboard));
public double OpacityGlobal
{
get { return (double)GetValue(OpacityGlobalProperty); }
set { SetValue(OpacityGlobalProperty, value); }
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
// if we have specified a parent
if (this.parentWindow != null)
{
// Get this window's handle
IntPtr HWND = new WindowInteropHelper(this.parentWindow).Handle;
// style of window?
int GWL_EXSTYLE = (-20);
// get - retrieves information about a specified window
GetWindowLong(HWND, GWL_EXSTYLE);
// set - changes the attribute of a specified window - I think this stops it being focused on
SetWindowLong(HWND, GWL_EXSTYLE, (IntPtr)(0x8000000));
}
}
public void Save(XmlElement element, XmlPersistContext cfill)
{
cfill.WriteDouble(OpacityGlobal, "OpacityGlobal", element);
}
public void Load(XmlElement element, XmlPersistContext cfill)
{
OpacityGlobal = cfill.ReadDouble("OpacityGlobal", element);
}
}
}