Click here to Skip to main content
15,887,248 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
Hi Friends
A very Happy New Year to everyone. :)
Recently, I have jumped into WPF based development and I currently I am trying to design a custom looking Application. I don't want Windows 7 Style Chrome (the Window Border). So, I am using WindowChrome Library which is available via Microsoft.Windows.Shell.

Now, here's where I am stuck. I have used

MainWindow.xaml
XML
<shell:WindowChrome GlassFrameThickness="0" />

This actually hides the Glass Border around the Window.
Then, I created few labels so that they represent the Minimize, Maximize and Close Buttons of a Window.
The Second point is, I defined the mouse events for these Labels to behave as the three different buttons present on rightmost side of the Window and they were working when I was using this
XML
<Window.WindowStyle>None</Window.WindowStyle>

but When I used WindowChrome I set it back to
XML
<Window.WindowStyle>SingleBorderWindow</Window.WindowStyle>

Now, The WindowChrome Class I used as shown above, it hide the Chrome (The glass border) but there is surely some overlapping issues with the original buttons and my custom made controls (the labels) and the mouse event is not firing on my labels now and so, I am unable to use them that way.

Now, I am trying to somehow connect the click event of these labels to the respective buttons of a normal Window So, that they only behave as a skinning to the original control.

Here is a screenshot of my design Click Here

Please give me some pointers to move ahead.
A very Thank you to everyone.

With Regards
Tushar Srivastava
Posted
Updated 1-Jan-14 8:13am
v4

1 solution

I'm not exactly sure how you have your labels set up (if you are using label, or textblock, or what), you should really post the code for the parts that don't work rather than for the parts that do...

In your XAML:

XML
<label mouseup="Close_MouseUp" />
<label mouseup="Minimize_MouseUp" />
<label mouseup="Maximize_MouseUp" />


In your code-behind:

C#
private void Close_MouseUp(object sender, MouseButtonEventArgs e)
{
    this.Close();
}

private void Maximize_MouseUp(object sender, MouseButtonEventArgs e)
{
    if (this.WindowState == System.Windows.WindowState.Maximized)
        this.WindowState = System.Windows.WindowsState.Normal;
    else
        this.WindowState = System.Windows.WindowsState.Maximized;
}

private void Minimize_MouseUp(object sender, MouseButtonEventArgs e)
{
    this.WindowState = System.Windows.WindowsState.Minimized;
}


I don't think there is a way to directly bind the click event of the label to the actual buttons of the window. If there is, somebody else will have a better answer.
 
Share this answer
 
Comments
Er. Tushar Srivastava 1-Jan-14 11:53am    
Actually, I surely would have mentioned this, I am sorry for that but actually, I have this already setup. Actually, I am unable to upload an image otherwise I would have shown you my layout. And, The way you have put it here, It is working fine. The problem is when I used WindowChrome, there is somekind of overlapping issue and so, my labels (I have styled them to look like the three buttons on the top of a window) are not taking these mouse events. Otherwise, my problem would have solved :) Thank you very much for your efforts :)
Ron Beyer 1-Jan-14 11:57am    
Please improve your question and add this information, its a very important detail that you left out.
Er. Tushar Srivastava 1-Jan-14 12:00pm    
Sure :) Thank you :)
Er. Tushar Srivastava 1-Jan-14 12:09pm    
Please have a look at the question now :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900