C
C#2y ago
FaNim

How to save and restore window position in wpf c#

Hello iam using .NET 7.0 and Properties doesnt work for me via code
10 Replies
TheRanger
TheRanger2y ago
doesnt work how? $details
MODiX
MODiX2y ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
FaNim
FaNimOP2y ago
i mean i cant event find any class named Properties as static reference
Althos
Althos2y ago
You mean the properties that get displayed in the Visual Studio Properties window?
FaNim
FaNimOP2y ago
I mean like in this code on internet
private void Load()
{
_windowTop = Properties.Settings.Default.WindowTop;
_windowLeft = Properties.Settings.Default.WindowLeft;
_windowHeight = Properties.Settings.Default.WindowHeight;
_windowWidth = Properties.Settings.Default.WindowWidth;
_windowState = Properties.Settings.Default.WindowState;
}

public void Save()
{
if (_windowState != System.Windows.WindowState.Minimized)
{
Properties.Settings.Default.WindowTop = _windowTop;
Properties.Settings.Default.WindowLeft = _windowLeft;
Properties.Settings.Default.WindowHeight = _windowHeight;
Properties.Settings.Default.WindowWidth = _windowWidth;
Properties.Settings.Default.WindowState = _windowState;

Properties.Settings.Default.Save();
}
}
private void Load()
{
_windowTop = Properties.Settings.Default.WindowTop;
_windowLeft = Properties.Settings.Default.WindowLeft;
_windowHeight = Properties.Settings.Default.WindowHeight;
_windowWidth = Properties.Settings.Default.WindowWidth;
_windowState = Properties.Settings.Default.WindowState;
}

public void Save()
{
if (_windowState != System.Windows.WindowState.Minimized)
{
Properties.Settings.Default.WindowTop = _windowTop;
Properties.Settings.Default.WindowLeft = _windowLeft;
Properties.Settings.Default.WindowHeight = _windowHeight;
Properties.Settings.Default.WindowWidth = _windowWidth;
Properties.Settings.Default.WindowState = _windowState;

Properties.Settings.Default.Save();
}
}
I do not have any properties class etc or maybe i need to download package to it idk
Althos
Althos2y ago
That's coming from a Settings file, which is something you have to add to your Properties folder by yourself
FaNim
FaNimOP2y ago
so i need to just create Properties folder and Settings class in it? i dont understand
Althos
Althos2y ago
You need to create a folder named Properties at the root of your project, then right-click on it -> Add new item -> Settings file
arion
arion2y ago
GitHub
GitHub - anakic/Jot: Jot is a library for persisting and applying ....
Jot is a library for persisting and applying .NET application state. - GitHub - anakic/Jot: Jot is a library for persisting and applying .NET application state.
FaNim
FaNimOP2y ago
okay thanks guy now i know everything
Want results from more Discord servers?
Add your server