Skip to content

danielchalmers/WpfWindowPlacement

Repository files navigation

WpfWindowPlacement NuGet

WINDOWPLACEMENT helpers for WPF.

Example

Define a WindowPlacement property.

using WpfWindowPlacement;
WindowPlacement MyPlacement { get; set; }

Now use it in the XAML attached property or code-behind functions.

XAML

xmlns:wp="clr-namespace:WpfWindowPlacement;assembly=WpfWindowPlacement"

<!-- Update size, position, and state on SourceInitialized and Closing -->
wp:WindowPlacementProperties.Placement="{Binding MyPlacement}"

Code-behind

using WpfWindowPlacement;

// Get window size, position, and state, and assign to MyPlacement.
MyPlacement = WindowPlacementFunctions.GetPlacement(this);

// Set window size, position, and state to the value of MyPlacement.
WindowPlacementFunctions.SetPlacement(this, MyPlacement);

License

MIT License