Mark Pitman

Does anyone know how to create an AppBar using WPF I have done it in WinForms using API calls, but I don't see a way to create the same behavior in WPF. Pointers to samples or just some code posted right here in the forum would be appreciated!


Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

Eddie Li

Mark, could you please describe the AppBar you are trying to build Is it like a floating toolbar type of app and how will it be used

Thanks.






Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

Mark Pitman

It would be a window docked to the side of the screen. It would still be visible if you maximized another window. Similar to the default behavior of the Windows Taskbar.




Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

Eddie Li

To accomplish that, you can start by creating a Window object and set its desired size and location based on the current screen resolution. The property you want to set to ensure it doesn't get hidden behind other windows is Topmost=true. You might also want to turn off the default WindowStyle=None so it take out the system buttons (max/min/close) and Window ResizeMode=NoResize, so you can control the resize behavior programmatically.

Hope this helps to get you started.

Thanks.






Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

Mark Pitman

That's a start, but it doesn't quite get me all the way there. If I maximize another window, it will be partially obscured by my topmost window. I want my "AppBar" to dock to the side of the screen. Then when any other window is maximized, it should only grow to the width of the screen minus the width of the "AppBar".




Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

tiomeg

I don't know what the purpose of your applictation is but im giving you one advice: 

Don't make a bar that reduces my desktop-size! Such kinds of bars are just annoying, look at...let's say the Vista sidebar. Seriously! How often do you actually have to look at your newsfeeds or play a picturepuzzle . Why should that cover 1/5 of my screen!

Make the bar hide automaticly instead and then make it reappear as a topmost-window when you move the mouse to the edge of the screen. If you want to read the news just pull the mouse to the right side of your screen and you'll have the bar there, takes 0,05sec longer to get to it but saves you 20% desktopspace the rest of the time.

 

Look at how Trillian[1] works when you have it docked, wonderful...

 

At least make autohide an option, lack of autohide is the ONLY reason why i don't use the Vista sidebar and i actually think that's a pretty good program otherwhise. Why would i want to use your program if it behaves the same way.

 

 

 just wan't to give you some thoughts from a user-perspective

[1]http://www.ceruleanstudios.com/





Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

Eddie Li

Hi Mark, to answer your follow up question, WPF Application Model unfortunately does not expose any functionality allowing you to do this. An option you have is to use HwndSource which gives you further ability to interop with Win32 such as specifying WindowStyles and creating hooks. This site (http://msdn.microsoft.com/library/default.asp url=/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/appbars.asp) talks about details on how to create an Appbar.

Hope this helps.






Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

Mark Pitman

HwndSource seems to be the answer here. Since I can't get the Handle of a WPF window, I need to host WPF content in an HwndSource and use the Handle provided to create the AppBar.

Thanks!




Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

tiomeg

void Window1_Loaded(object sender, RoutedEventArgs e)

{

int hwndMe = new System.Windows.Interop.WindowInteropHelper(this).Handle;

}

Gives you the handle of your window





Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

Hassmann

Hello Mark,

I have exactly the same problem. Have you solved it

Andreas.

public[@]hassmann.com





Re: Windows Presentation Foundation (WPF) Creating an AppBar in WPF

Thomas Danecker

Hi Mark,

I'm also working on such an AppBar with WPF. I use some PInvokes to register may AppBar, see http://msdn.microsoft.com/library/default.asp url=/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/appbars.asp for details on the required PInvokes.

http://www.pinvoke.net is also a good hint.

My current problem is, that most of the time my window is moved away from the previously set position. Curiously sometime it works.

Thomas