protected override void OnAttached() { base.OnAttached(); if (AssociatedObject.IsLoaded) { _snapManager = new WindowSnapManager(new WindowInteropHelper(AssociatedObject).Handle); } else { AssociatedObject.SourceInitialized += AssociatedObjectOnSourceInitialized; } }
private void AssociatedObjectOnSourceInitialized(object sender, EventArgs e) { AssociatedObject.SourceInitialized -= AssociatedObjectOnSourceInitialized; _snapManager = new WindowSnapManager(new WindowInteropHelper(AssociatedObject).Handle); }