DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Reactive Programming
  • SRE vs. DevOps
  • 5 Key Concepts for MQTT Broker in Sparkplug Specification
  • Chaining API Requests With API Gateway

Trending

  • Reactive Programming
  • SRE vs. DevOps
  • 5 Key Concepts for MQTT Broker in Sparkplug Specification
  • Chaining API Requests With API Gateway

Drawing a Zune-like Control Bar in a WPF Application

Toni Petrina user avatar by
Toni Petrina
·
Mar. 29, 12 · Interview
Like (0)
Save
Tweet
Share
7.40K Views

Join the DZone community and get the full member experience.

Join For Free

So you want to build Zune like applications? Here is the recipe for adjusting the necessary stuff borrowed from an excellent blog post over at bonus bits. First, create a new WPF application project and run it. You will get something like this:

Basic metroization

Now adjust the following properties for the window:

WindowStartupLocation="CenterScreen"
WindowStyle="None"
ResizeMode="NoResize"
FontFamily="Segoe UI"
Background="Transparent"
AllowsTransparency="True"

Main design will consist of a Border element containing the main Gridelement. Here is the complete XAML:

<Border BorderBrush="White" BorderThickness=".5" Margin="10">
    <Border.Effect>
        <DropShadowEffect BlurRadius="10" Color="#82000000" />
    </Border.Effect>
    <Grid>
        <Grid.Background>
            <RadialGradientBrush>
                <GradientStop Color="#FF666666" Offset="0" />
                <GradientStop Color="#FF444444" Offset=".6" />
                <GradientStop Color="#FF444444" Offset="1" />
            </RadialGradientBrush>
        </Grid.Background>

        <TextBlock Text="Hello Metro" Foreground="WhiteSmoke" Margin="20,12" FontSize="48"/>
    </Grid>
</Border>

If you run the program now, here is what you should see:

This window is unmovable and cannot be resized. If you want any of that, consider the blog post mentioned above.

The control box

Standard control box buttons are drawn using the Marlett font where maximize/minimize/restore/close glyphs are stored. You can view them using the Character Map program accessible via the Start menu. Add the following XAML code inside the main Grid element:

<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="4">
    <StackPanel.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontFamily" Value="Marlett" />
        </Style>
    </StackPanel.Resources>
    <TextBlock Text="r" />
</StackPanel>

Character r is mapped to the close glyph in the Marlett font and the window should look like:

Add the rest of the desired glyphs as a separate TextBox elements. You can copy them directly from the Character Map or you can use. For the maximize button glyph you should use 1.

Change style as required, add hover effect, mouse click handlers and you are good to go. Happy designing.

Windows Presentation Foundation application

Published at DZone with permission of Toni Petrina, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Reactive Programming
  • SRE vs. DevOps
  • 5 Key Concepts for MQTT Broker in Sparkplug Specification
  • Chaining API Requests With API Gateway

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: