Silverlight(3) - 2.0控件之Border, Button, Calendar, Canvas, CheckBox, ComboBox
2008-11-14 11:50:54 来源:WEB开发网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
Tags:Silverlight 控件 Border
编辑录入:爽爽 [复制链接] [打 印]- ››silverlight全屏显示图片
- ››控件一:Gallery 之无限循环的问题
- ››控件一:Gallery 之基础用法
- ››Silverlight MVVM 模式(一) 切近实战
- ››Silverlight for Windows Phone 7开发系列(1):...
- ››Silverlight for Windows Phone 7开发系列(2):...
- ››Silverlight for Windows Phone 7开发系列(3):...
- ››Silverlight for Windows Phone 7开发系列(4):...
- ››Silverlight for Symbian
- ››Borders推电子书店 支持iPhone与Android等
- ››Silverlight3系列(四)数据绑定 Data Binding 1
- ››silverlight2 游戏 1 你能坚持多少秒
- 中查找“Silverlight(3) - 2.0控件之Border, Button, Calendar, Canvas, CheckBox, ComboBox”更多相关内容
- 中查找“Silverlight(3) - 2.0控件之Border, Button, Calendar, Canvas, CheckBox, ComboBox”更多相关内容
- 上一篇:Silverlight(4) - 2.0控件之DataGrid, DatePicker, Grid, GridSplitter, HyperlinkButton, Image
- 下一篇:Silverlight(2) - 1.0实例之支持录音和回放的钢琴(Silverlight+ASP.NET AJAX+DLINQ)
更多精彩
赞助商链接