WEB开发网
开发学院图形图像Flash Silverlight(3) - 2.0控件之Border, Button, Cale... 阅读

Silverlight(3) - 2.0控件之Border, Button, Calendar, Canvas, CheckBox, ComboBox

 2008-11-14 11:50:54 来源:WEB开发网   
核心提示: CheckBox.xaml.csusing System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Contro

CheckBox.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
  
using System.Windows.Browser;
  
namespace Silverlight20.Control
{
  public partial class CheckBox : UserControl
  {
    public CheckBox()
    {
      InitializeComponent();
    }
  
    private void Button_Click(object sender, RoutedEventArgs e)
    {
      HtmlWindow html = HtmlPage.Window;
      html.Alert(string.Format("chk1: {0}rnchk2: {1}rnchk3: {2}rnchk4: {3}",
        chk1.IsChecked, chk2.IsChecked, chk3.IsChecked, chk4.IsChecked));
    }
  }
}

6、ComboBox.xaml

<UserControl x:Class="Silverlight20.Control.ComboBox"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel HorizontalAlignment="Left">
    
    <!--
    XAML方式构造ComboBox
    -->
    <ComboBox x:Name="cbo" Width="200" Margin="5">
      <ComboBoxItem Content="ComboBoxItem1" />
      <ComboBoxItem Content="ComboBoxItem2" />
      <ComboBoxItem Content="ComboBoxItem3" />
    </ComboBox>
    
    <!--
    后台邦定方式构造ComboBox
    DisplayMemberPath - 数据源中需要被显示出来的字段名称
    MaxDropDownHeight - 下拉框的最大下拉高度
    -->
    <ComboBox x:Name="cbo2" DisplayMemberPath="Name" MaxDropDownHeight="100" Width="200" Margin="5" />
    
  </StackPanel>
</UserControl>

ComboBox.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
  
namespace Silverlight20.Control
{
  public partial class ComboBox : UserControl
  {
    public ComboBox()
    {
      InitializeComponent();
  
      BindData();
    }
  
    void BindData()
    {
      var source = new Data.SourceData();
  
      // 设置 ComboBox 的数据源
      cbo2.ItemsSource = source.GetData().Take(10);
    }
  }
}

OK

上一页  1 2 3 4 5 6 

Tags:Silverlight 控件 Border

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接