In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to use Style in Silverlight 2, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Style is simply a collection of attribute values.
The effect is similar to CSS. Defining Style in Silverlight 2 can only be used for the same type of Element. The code is as follows:
< Style x:Key="ButtonStyleTwo" TargetType="Button"> < Setter Property="FontFamily" Value="Arial" /> < Setter Property="FontSize" Value="40" /> < Setter Property="Foreground" Value="Blue" /> < Setter Property="Background"> < /Style>This is a defined Style that can only be used with Button components to see how it works, embedding Style directly into Button:
< Button Content="Button"> < Button.Style> < Style TargetType="Button"> < Setter Property="FontFamily" Value="Arial" /> < Setter Property="FontSize" Value="40" /> < Setter Property="Foreground" Value="Blue" /> < Setter Property="Background"> < Setter.Value> < LinearGradientBrush> < GradientStop Color="Green" Offset="0"> < /GradientStop> < GradientStop Color="Red" Offset="1"> < /GradientStop> < /LinearGradientBrush> < /Setter.Value> < /Setter> < /Style> < /Button.Style> < /Button>Of course, you can also set Style by Resource, setting two Style:ButtonStyleOne and ButtonStyleTwo respectively
ButtonStyleOne is set to the default Style,ButtonStyleTwo to switch Style after clicking Button.
Style activity for Silverlight 2: XAML Code:
< UserControl x:Class="SilverlightTest.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400"> < UserControl.Resources> < Style x:Key="ButtonStyleOne" TargetType="Button"> < Setter Property="FontFamily" Value="Georgia" /> < Setter Property="FontSize" Value="40" /> < Setter Property="Foreground" Value="SlateGray" /> < Setter Property="Background"> < Setter.Value> < LinearGradientBrush> < GradientStop Color="Blue" Offset="0"> < /GradientStop> < GradientStop Color="Yellow" Offset="1"> < /GradientStop> < /LinearGradientBrush> < /Setter.Value> < /Setter> < /Style> < Style x:Key="ButtonStyleTwo" TargetType="Button"> < Setter Property="FontFamily" Value="Arial" /> < Setter Property="FontSize" Value="40" /> < Setter Property="Foreground" Value="Pink" /> < Setter Property="Background"> < Setter.Value> < LinearGradientBrush> < GradientStop Color="Green" Offset="0"> < /GradientStop> < GradientStop Color="Red" Offset="1"> < /GradientStop> < /LinearGradientBrush> < /Setter.Value> < /Setter> < /Style> < /UserControl.Resources> < StackPanel x:Name="LayoutRoot" Background="White"> < Button x:Name="TestButton" Content="A Customized Button" Style="{StaticResource ButtonStyleOne}" Click="Button_Click"> < /Button> < /StackPanel> < /UserControl>Use C # to switch Sytle, as follows:
Private void Button_Click (object sender, RoutedEventArgs e) {/ / switch Style:ButtonStyleTwo TestButton.Style = this.Resources ["ButtonStyleTwo"] as Style; / / modify the Button text TestButton.Content = "Style Changed";} above is all the content of this article "how to use Style in Silverlight 2". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.