有關Silverlight 3.0中的ChildWindow樣式以使其看起來像Windows 7 Aero玻璃窗口的任何示例?SL3透明/玻璃兒童窗戶?
我試着改變背景等,overlaybrush和overlayopacity屬性,包括啓用RootVisual,因爲每當顯示子窗口時都禁用它,但目前爲止沒有運氣。
任何示例或建議將不勝感激。
謝謝。
有關Silverlight 3.0中的ChildWindow樣式以使其看起來像Windows 7 Aero玻璃窗口的任何示例?SL3透明/玻璃兒童窗戶?
我試着改變背景等,overlaybrush和overlayopacity屬性,包括啓用RootVisual,因爲每當顯示子窗口時都禁用它,但目前爲止沒有運氣。
任何示例或建議將不勝感激。
謝謝。
我沒有適合您的Windows 7 Aero Glass風格,但是您將必須替換ChildWindow的默認控件模板和風格,以獲得您的外觀,而不僅僅是更改屬性(背景,OverlayBrush, OverlayOpacity)控件上。
MSDN reference page for ChildWindow Styles and Templates檢查ChildWindow的零件和狀態模型,幷包含用於默認ControlTemplate的XAML。我想這將是您開始的最佳場所,然後您必須在Blend中調整修改後的模板版本,才能找到您想要的方式。
我不相信有任何需要重新啓用應用程序的RootVisual,只要你還想要ChildWindow的標準模式類型的行爲。
我想補充一點,您可以通過不僅修改不透明度和其他設置,而且添加一個背景,該背景具有許多在Silverlight 3中找到的效果。您可以使用Blend嘗試使用值。 - DropShadowEffect - BlurEffect – 2010-02-18 20:20:45
您可以使用this article
上的模板ChildWindow
與this article
創建Glass Theme in Silverlight
創建你想要的!
大多數有經驗的設計人員應該能夠通過模板自定義ChildWindow,但是您將無法輕鬆獲得真正的Windows Aero主題,因爲ChildWindow根本不是爲此設計的。此外,他們嚴重缺乏遵守標準。 我已經發布了一個博客,詳細介紹UX的重要性(除了玻璃風格)。查看http://intersoftpt.wordpress.com/2010/05/21/clientui-part-4-rich-ui-meets-iso-standards/ – 2010-07-04 02:02:55
更新:我寫了一篇博客文章這也http://josheinstein.com/blog/index.php/2010/07/windows-7-style-aero-childwindow-template/
我刪除了我以前的答案,因爲我決定採取另一種刺在Windows 7中的Aero風格ChildWindow。我似乎仍然無法獲得模糊效果,因爲模糊只會模糊所應用元素的內容。如果該元素具有透明度,則通過它顯示的任何內容都不會模糊。我想這可以用一些可變的位圖或像素着色器來完成,但目前我還沒有真正做到這一點。
但是,在Blend中使用真棒「漸變吸管」工具,我設法讓我的標題欄和關閉按鈕看起來非常類似於Windows 7標題。屏幕截圖(漂亮)和XAML(不太漂亮)如下。
ChildWindow http://josheinstein.com/blog/wp-content/uploads/2010/07/ChildWindowWindows7Aero.png
<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">
<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>
也許你應該分享在你有這麼遠的樣式模板XAML?順便說一句,「啓用RootVisual」是什麼意思? – AnthonyWJones 2010-01-23 09:14:56