sammarks
sammarks

Reputation: 466

Bring Window Buttons to Front

I'm currently developing a Twitter application for Windows, similar to the Twitter client for OSX.

I'm using the Windows Shell Extensions library found here to make the entire window Aero, and be able to extend beyond the bounds of the designated window location.

I want the window buttons (Minimize, Maximize, Close) to be shown over top of the grid with the white background. This is a functionality that I thought would have been built into Windows, but apparently I'm wrong.

The two images below illustrate my point. In the second image, I want the window buttons to take precedence over the white-background grid, not the other way around like it's shown.

Is there some kind of code snippet or XAML-snippet that'll help me? Has anyone else ever had this problem before?

Window sized so that buttons show Window sized so that buttons don't show.

Upvotes: 2

Views: 939

Answers (2)

sammarks
sammarks

Reputation: 466

I stumbled upon a simple, yet dirty solution. I just made a path to go around the outside of the Windows buttons, and set the background of the outside to white, or whatever background color I was using. Then I just pieced rectangles together to make it look nice.

Here's the resulting code:

<Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Row="0" Height="20">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="1.0*" />
      <ColumnDefinition Width="105" />
      <ColumnDefinition Width="5" />
    </Grid.ColumnDefinitions>
    <Rectangle Grid.Column="0" Fill="#FFFFFFFF" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
    <Path HorizontalAlignment="Stretch" Grid.Column="1" Stretch="Fill" VerticalAlignment="Bottom" Height="20" Fill="#FFFFFFFF" Data="M 0,4.11334L 4.008,4.11334C 1.792,4.11334 0,2.27332 0,0L 0,4.11334 Z M 140,4.11334L 135.957,4.11334C 138.192,4.11334 140,4.11334 140,0L 140,4.11334 Z  " />
    <Border Grid.Column="2" CornerRadius="0, 10, 0, 0" Background="#FFFFFFFF" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
  </Grid>

And here's the resulting image:

enter image description here

Upvotes: 2

Taha Paksu
Taha Paksu

Reputation: 15616

you should hide your minimize maximize and close buttons and draw your own like described here.

http://winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize-restore-and-close-and-the-icon-of-a-window/

Upvotes: 0

Related Questions