zoukankan      html  css  js  c++  java
  • Pro Silverlight 3 in C# XAML Resources

    1. The Resources Collection

    <UserControl x:Class="EightBall.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
    <LinearGradientBrush x:Key="BackgroundBrush">
    <LinearGradientBrush.GradientStops>
    <GradientStop Offset="0.00" Color="Yellow" />
    <GradientStop Offset="0.50" Color="White" />
    <GradientStop Offset="1.00" Color="Purple" />
    </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    </UserControl.Resources>
    ...
    </UserControl>
    <Grid x:Name="grid1" Background="{StaticResource BackgroundBrush}">

    2.The Hierarchy of Resources

    <UserControl x:Class="Resources.ResourceHierarchy"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
    <StackPanel><StackPanel.Resources>
    <LinearGradientBrush x:Key="ButtonFace">
    <GradientStop Offset="0.00" Color="Yellow" />
    <GradientStop Offset="0.50" Color="White" />
    <GradientStop Offset="1.00" Color="Purple" />
    </LinearGradientBrush>
    </StackPanel.Resources>
    <Button Content="Click Me First" Margin="5"
    Background="{StaticResource ButtonFace}"></Button>
    <Button Content="Click Me Next" Margin="5"
    Background="{StaticResource ButtonFace}"></Button>
    </StackPanel>
    </Grid>
    </UserControl>

    3. Application.Resources

    <Application xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SilverlightApplication1.App">
    <Application.Resources>
    <LinearGradientBrush x:Key="ButtonFace">
    <LinearGradientBrush.GradientStops>
    <GradientStop Offset="0.00" Color="Yellow" /><GradientStop Offset="0.50" Color="White" />
    <GradientStop Offset="1.00" Color="Purple" />
    </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    </Application.Resources>
    </Application>
     
    4.Accessing Resources in Code
    LinearGradientBrush brush = (LinearGradientBrush)this.Resources["ButtonFace"];
    // Swap the color order.
    Color color = brush.GradientStops[0].Color;
    brush.GradientStops[0].Color = brush.GradientStops[2].Color;
    brush.GradientStops[2].Color = color;
     
    SolidColorBrush brush = new SolidColorBrush(Colors.Yellow);
    this.Resources["ButtonFace"] = brush;

    5. Organizing Resources with Resource Dictionaries

    <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <LinearGradientBrush x:Key="ButtonFace">
    <LinearGradientBrush.GradientStops>
    <GradientStop Offset="0.00" Color="Yellow" /><GradientStop Offset="0.50" Color="White" />
    <GradientStop Offset="1.00" Color="Purple" />
    </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    </ResourceDictionary>
    <Application xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SilverlightApplication1.App">
    <Application.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="ElementBrushes.xaml" />
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Application.Resources>
    </Application>
    <Application.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="BasicBrushes.xaml" />
    <ResourceDictionary Source="ButtonBrushes.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <LinearGradientBrush x:Key="GraphicalBrush1" ... ></LinearGradientBrush>
    <LinearGradientBrush x:Key="GraphicalBrush2" ... ></LinearGradientBrush>
    </ResourceDictionary>
    </Application.Resources>

    Book Mark:93

  • 相关阅读:
    mac上的键盘生活——打字训练

    011-黑盒测试的测试用例常见设计方法都有哪些?请分别以具体的例子来说明这些方法在测试用例设计工作中的应用
    010-如何测试一个 纸杯?
    009-条软件缺陷(或者叫 Bug)记录都包含了哪些内容?如何提交高质量的软件缺陷(Bug)记录?
    008-黑盒测试和白盒测试的优缺点
    007-测试人员在软件开发过程中的任务是什么?
    006- 软件产品质量特性是什么?
    005-目前主要的测试用例设计方法是什么?
    007-软件测试分类
  • 原文地址:https://www.cnblogs.com/zhanxp/p/1709403.html
Copyright © 2011-2022 走看看