C
C#17mo 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
TheRanger17mo ago
doesnt work how? $details
MODiX
MODiX17mo 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
FaNim17mo ago
i mean i cant event find any class named Properties as static reference
Althos
Althos17mo ago
You mean the properties that get displayed in the Visual Studio Properties window?
FaNim
FaNim17mo 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
Althos17mo ago
That's coming from a Settings file, which is something you have to add to your Properties folder by yourself
FaNim
FaNim17mo ago
so i need to just create Properties folder and Settings class in it? i dont understand
Althos
Althos17mo 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
arion17mo 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
FaNim17mo ago
okay thanks guy now i know everything
Want results from more Discord servers?
Add your server
More Posts