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

    3.1. XAML Basics

     <UserControl x:Class="SilverlightApplication1.MainPage"
     xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
     xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
     xmlns:d=http://schemas.microsoft.com/expression/blend/2008
     xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
     mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
     <Grid x:Name="LayoutRoot">
     </Grid>
     </UserControl>
    
    2. XAML Namespaces
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    3. Design Namespaces
      mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    4.Custom Namespaces
      xmlns:w="clr-namespace:Widgets"
      <w:HotButton Text="Click Me!" Click="DoSomething"></w:HotButton>
    5. Properties and Events in XAML
      
    <Grid x:Name="grid1">
    <Grid.Background>
    <LinearGradientBrush>
    <LinearGradientBrush.GradientStops>
    <GradientStop Offset="0.00" Color="Yellow" />
    <GradientStop Offset="0.50" Color="White" />
    <GradientStop Offset="1.00" Color="Purple" />
    </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    </Grid.Background>
    ...
    </Grid>

    -----------------------------------------------------------------------

    LinearGradientBrush brush = new LinearGradientBrush();
    GradientStop gradientStop1 = new GradientStop();
    gradientStop1.Offset = 0;
    gradientStop1.Color = Colors.Yellow;
    brush.GradientStops.Add(gradientStop1);
    GradientStop gradientStop2 = new GradientStop();
    gradientStop2.Offset = 0.5;
    gradientStop2.Color = Colors.White;
    brush.GradientStops.Add(gradientStop2);
    GradientStop gradientStop3 = new GradientStop();
    gradientStop3.Offset = 1;
    gradientStop3.Color = Colors.Purple;
    brush.GradientStops.Add(gradientStop3);
    grid1.Background = brush;
     
    6. Nesting Elements
    <Grid x:Name="grid1">
    ...
    <TextBox x:Name="txtQuestion" ... >
    </TextBox>
    <Button x:Name="cmdAnswer" ... >
    </Button>
    <TextBox x:Name="txtAnswer" ... >
    </TextBox>
    </Grid>

    -----------------------------------------------

    txtQuestion = new TextBox();
    ...
    grid1.Children.Add(txtQuestion);
    cmdAnswer = new Button();
    ...
    grid1.Children.Add(cmdAnswer);
    txtAnswer = new TextBox();
    ...
    grid1.Children.Add(txtAnswer);

    ------------------------------------------------------

    private void Clear(DependencyObject element)
    {
    // If this is a text box, clear the text.
    TextBox txt = element as TextBox;
    if (txt != null) txt.Text = "";
    // Check for nested children.
    int children = VisualTreeHelper.GetChildrenCount(element);
    for (int i = 0; i < children; i++)
    {
    DependencyObject child = VisualTreeHelper.GetChild(element, i);
    Clear(child);
    }
    }

  • 相关阅读:
    JAVA访问权限控制[zhuan]
    Netstat简介
    查看cpu性能和磁盘空间
    简单linux查询
    linux 三剑客命令(grep,sed ,awk)
    同步、异步的使用场景及好处
    AJAX中同步和异步的区别和使用场景
    在SpringBoot中用SpringAOP实现日志记录功能
    springboot使用@Aspect实现AOP记录日志讲解
    Spring:获取容器中的Bean
  • 原文地址:https://www.cnblogs.com/zhanxp/p/1709400.html
Copyright © 2011-2022 走看看