I'm trying to build a WPF application with a slide-out drawer like a lot of macOS applications have:
How would I go about implementing this?
I'm trying to build a WPF application with a slide-out drawer like a lot of macOS applications have:
How would I go about implementing this?
In WPF you would typically display something like that using a separate child Window or a Popup within your current window. The Popup is going to be constrained within the borders of your parent window whereas the Window can be anywhere on the screen. You can launch a new window fairly easily:
var window = new Window();
// Initialize your content to whatever you want in the window
window.Content = new TextBlock() { Text = "Hello world };
window.Show();
// Use .Show() if you want to allow users to interact with both windows at the same time
// Otherwise use .ShowDialog() to force the user to interact/dismiss the child first
You'll need to control the position of the child window somehow if you want it to be tied to the side of your parent window. This SO article describes controlling window location. You'll probably want to do this during an event on your parent window that makes sense, like SizeChanged and LocationChanged.
Lastly, depending on how you want the window frame to look (I'd imagine the "drawer" isn't supposed to look like a full blown window just stuck to the side of your parent window) I would at least change the child's WindowStyle. Further, you could make the window transparent and totally restyle the content to look much more like what you have provided as an image.
This is roughly what you're looking for. I hope this helps.