tags:

views:

260

answers:

4

Any examples on styling the ChildWindow in Silverlight 3.0 to look like the Windows 7 Aero glass windows?

I've tried changing the background etc., overlaybrush, and overlayopacity properties, including enabling the RootVisual since it is disabled whenever a child window is shown, but no luck so far.

Any examples or suggestions would be greatly appreciated.

Thanks.

+1  A: 

I don't have a Windows 7 Aero Glass style for you, but you are going to have to replace the default control template for the ChildWindow and style that to get your look instead of just changing properties (Background, OverlayBrush, OverlayOpacity) on the control.

The MSDN reference page for ChildWindow Styles and Templates goes over the parts and states model for the ChildWindow and includes the XAML for the default ControlTemplate. I would guess that would be the best place for you to start, and then you'll have to tweak a modified version of the template in Blend to get looking the way you want.

I don't believe there is any need to re-enable the application's RootVisual as long as you still want the standard modal-type behavior of the ChildWindow.

Dan Auclair
I'd add, that you may be able to simulate this by not only modifying the opacity and other settings, but adding a background that has a number of effects that are found in Silverlight 3. You could experiment with values using Blend.- DropShadowEffect- BlurEffect
Jeff Wilcox
A: 

Chris, we have complete control lineups that allows you to create commercial-class UIs, such as Windows-7 Aero Windowing, Apple-style Desktop, and much more.

Check out http://tinyurl.com/34248lz

Hope this helps.

James
When you're a commercial player(Intersoft, in this case) in this space, it's good style to say so, isn't it?
GreenIcicle
Yep, all our styles are professionally designed. Our main difference compared with other tools is that, our windows aren't just shiny - they also comply to ISO-standards usability factors required for building rich user experiences. This includes input modality, focus scope, keyboard focus and many more that aren't implemented by MSFT or other libraries.Check out http://intersoftpt.wordpress.com/2010/05/21/clientui-part-4-rich-ui-meets-iso-standards/
James
Tired of seeing the same advertisment for Intersoft on every SL post I see. (Even ones posted 6 months ago) "We have a product that does that" doesn't really solve my problem. If it did, I'd just Google for products that do what I want, rather than come to Stack Overflow.
Jeff Sheldon
Hi Jeff, thank you for your feedback.I'm not doing any advertising here. Many Silverlight developers are so frustrated with the lacking of features in Silverlight, our intention here is to simply providing information for RIA developers to build better Silverlight application with decent UX standards.I definitely can't control how people see my posts, many see them positively, few see it negatively. FYI, we've attracted even Adobe and JavaFX developers to give a try on Silverlight. Isn't that a good thing? :)Hope this helps,James.
James
A: 

You can use this article on Templating ChildWindow with this article on creating Glass Theme in Silverlight to create what you want!

decyclone
Most experienced designers should be able to customize the ChildWindow via Template, but you won't be able to easily get a true Windows Aero theme because ChildWindow is simply not designed for that. Furthermore, they're greatly lacking in standards-compliance.I've posted a blog that details the importance of UX (in addition to the glassy styles). Check out http://intersoftpt.wordpress.com/2010/05/21/clientui-part-4-rich-ui-meets-iso-standards/
James
A: 

Update: I wrote a blog post about this too http://josheinstein.com/blog/index.php/2010/07/windows-7-style-aero-childwindow-template/

I deleted my previous answer because I decided to take another stab at a Windows 7 style Aero ChildWindow. I still can't seem to get a blur effect to work right because blur only blurs the contents of the element it's applied to. If that element has transparency, anything that shows through it is NOT blurred. I guess it could be done with some trickery using a writable bitmap or a pixel shader but I'm not really up for that at the moment.

However, using the awesome "gradient eyedropper" tool in Blend I managed to get my title bar and close button to look very similar to a Windows 7 caption. Screen shot (pretty) and XAML (not so pretty) are below.

ChildWindow

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:s="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"&gt;

  <Style x:Key="AeroWindowCloseButton" TargetType="Button">
    <Setter Property="Background">
      <Setter.Value>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
          <GradientStop Color="#FFEEB3AC" Offset="0.009"/>
          <GradientStop Color="#FFDA8578" Offset="0.402"/>
          <GradientStop Color="#FFC64D38" Offset="0.459"/>
          <GradientStop Color="#FFC84934" Offset="0.598"/>
          <GradientStop Color="#FFD48671" Offset="0.885"/>
          <GradientStop Color="#FFE8BBAE" Offset="0.943"/>
        </LinearGradientBrush>
      </Setter.Value>
    </Setter>
    <Setter Property="BorderBrush" Value="#FF5E5E5E"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="Padding" Value="3"/>
    <Setter Property="Width" Value="45"/>
    <Setter Property="Height" Value="20"/>
    <Setter Property="IsTabStop" Value="False"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="Button">
          <Border
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            CornerRadius="0,0,3,3">
            <Path
              Fill="{TemplateBinding Foreground}"
              Width="11"
              Height="10"
              Stretch="Fill"
              Data="F1 M 6.742,3.852 L 9.110,1.559 L 8.910,0.500 L 6.838,0.500 L 4.902,2.435 L 2.967,0.500 L 0.895,0.500 L 0.694,1.559 L 3.062,3.852 L 0.527,6.351 L 0.689,7.600 L 2.967,7.600 L 4.897,5.575 L 6.854,7.600 L 9.115,7.600 L 9.277,6.351 L 6.742,3.852 Z">
              <Path.Stroke>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                  <GradientStop Color="#FF313131" Offset="1"/>
                  <GradientStop Color="#FF8E9092" Offset="0"/>
                </LinearGradientBrush>
              </Path.Stroke>
            </Path>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="AeroWindow" TargetType="s:ChildWindow">
    <Setter Property="Background" Value="White"/>
    <Setter Property="BorderBrush" Value="#FF5E5E5E"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="OverlayBrush" Value="Transparent"/>
    <Setter Property="OverlayOpacity" Value="0"/>
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
    <Setter Property="Padding" Value="5"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="TabNavigation" Value="Cycle"/>
    <Setter Property="UseLayoutRounding" Value="True"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="s:ChildWindow">
          <Grid x:Name="Root">

            <!-- OVERLAY BEHIND CHILDWINDOW -->
            <Grid
              x:Name="Overlay"
              Background="{TemplateBinding OverlayBrush}"
              Opacity="{TemplateBinding OverlayOpacity}"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Top"/>

            <!-- WINDOW CONTAINER -->
            <Grid x:Name="ContentRoot" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">

              <!-- GLASS BACKGROUND AND BORDER -->
              <!--
          NOTE: This border should not physically contain the rest of the
          window contents because it has an opacity setting that would
          affect all of its children. Instead, a second border is directly
          above it in the z-order and contains the child elements.
          -->
              <Border
                x:Name="Chrome"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="4"
                Opacity="0.9">
                <Border.Background>
                  <LinearGradientBrush MappingMode="Absolute" StartPoint="0,0" EndPoint="1920,0">
                    <GradientStop Color="#FFADC9E5" Offset="0.010"/>
                    <GradientStop Color="#FFA7C2DC" Offset="0.069"/>
                    <GradientStop Color="#FFB7D2EC" Offset="0.084"/>
                    <GradientStop Color="#FFB7D2EC" Offset="0.146"/>
                    <GradientStop Color="#FFA8C4DE" Offset="0.168"/>
                    <GradientStop Color="#FFB8D3ED" Offset="0.455"/>
                    <GradientStop Color="#FFA6C1DB" Offset="0.518"/>
                    <GradientStop Color="#FFB6D1EB" Offset="0.543"/>
                    <GradientStop Color="#FFA7C2DC" Offset="0.604"/>
                    <GradientStop Color="#FFB7D2EC" Offset="0.618"/>
                    <GradientStop Color="#FFB7D2EC" Offset="0.700"/>
                    <GradientStop Color="#FFABC6E1" Offset="0.722"/>
                    <GradientStop Color="#FFB1CEEA" Offset="0.778"/>
                  </LinearGradientBrush>
                </Border.Background>
              </Border>

              <!-- WINDOW CONTENTS -->
              <!-- 
          NOTE: This element will not have a visible border. The Chrome element
          provides the visible border but this element needs to have a matching
          thickness and corner radius so that the contents of the window are
          "pushed in" by the same amount.
          -->
              <Border BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4">
                <Grid>
                  <Grid.RowDefinitions>
                    <RowDefinition Height="25"/>
                    <RowDefinition/>
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto"/>
                  </Grid.ColumnDefinitions>
                  <ContentControl
                    Content="{TemplateBinding Title}"
                    Foreground="#FF393939"
                    FontWeight="Bold"
                    VerticalAlignment="Center"
                    Margin="6,0,6,0"
                    Grid.Row="0"
                    Grid.Column="0"/>
                  <Button
                    x:Name="CloseButton"
                    Style="{StaticResource AeroWindowCloseButton}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="1,0,1,1"
                    VerticalAlignment="Top"
                    Margin="0,0,5,0"
                    Grid.Row="0"
                    Grid.Column="1"/>
                  <Border
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Margin="{TemplateBinding Padding}"
                    Grid.Row="1"
                    Grid.ColumnSpan="2">
                    <ContentPresenter
                      x:Name="ContentPresenter"
                      Content="{TemplateBinding Content}"
                      ContentTemplate="{TemplateBinding ContentTemplate}"
                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                  </Border>
                </Grid>
              </Border>
            </Grid>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>
Josh Einstein