❔ Help with minimising, maximisng and closing a window
I add a close, maximise and minimise button to my application, however they don't seem to be working. Can I get some help?
28 Replies
this shouldnt be in the viewmodel imo
also what does "not work" mean
what happens when you click them
Nothing, as is in you press them and there's no change
all of them?
Yup
is the command being executed?
put a breakpoint
I don't think so
Should I add the breakpoint, after the command is executed
put it on the opening bracket
I have, I'll be gone for 15 sorry, need to sort something out
np
Yeah, just put it in code-behind @AceChewy
And remove the
Application.Current.MainWindow
partyeah make it reference the current window
and close the window not the application
but thats after we figure out the current issue
Just as a side-note, to save yourself some time, you may want to use one of the ready-made $wpfuilibs
MahApps
https://github.com/MahApps/MahApps.Metro
ModernWPF
https://github.com/Kinnara/ModernWpf
Adonis UI
https://github.com/benruehl/adonis-ui
Material Design
https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit
Biaui
https://github.com/YoshihiroIto/Biaui
HandyControl
https://github.com/HandyOrg/HandyControl
WPFUI (Windows 11 inspired)
https://github.com/lepoco/wpfui
Waves (WPF/Avalonia/More)
https://github.com/waves-framework/waves.ui.wpf
Most of them offer title bar area customization, including extending the window client area to title bar area.
Speaking of your commands not being executed, you either did not set the appropriate DataContext or did not properly bind the commands to your buttons.
this looks like a custom design anyway
Ok, I’ll try they in a minute
Can’t get back to my computer for a while so I’ll try it later and let you know if it works
you define those commands, but nothing actually initializes them with methods you defined later
you also dont seem to set the datacontext of your window anywhere
meaning, even if you initialized the commands somewhere, the bindings wont work, because they have nothing to bind to
as you didnt provide a source for your binding
How would I go about setting the data context of my window
its literally a property, so you assign it a value like anywhere else in c# code
yourWindow.DataContext = someThing;
Where would be an appropriate place to set the context?
In App.xaml.cs if you use DI, otherwise in .xaml or .xaml.cs of your window
Right I've done what you've said
I already had the data context set in the xaml file, completely forgot about that
And it works now, so great
Before I close this thread, do any of you know how I can change the name of my applicaiton without having to manually change it everywhere in the code where it's referenced?
I realised I mispelt Utilities
Help with how to get the application name to display in the tab below would also be helpful:
You would just set a property on the viewmodel that has your application name and bind to that
Just set window title
Thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.