Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton
2008-11-14 11:50:44 来源:WEB开发网TextBox.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 TextBox : UserControl
{
public TextBox()
{
InitializeComponent();
}
private void TextBox_SelectionChanged(object sender, RoutedEventArgs e)
{
lblMsg.Text = ((System.Windows.Controls.TextBox)sender).SelectedText;
}
}
}
7、ToggleButton.xaml
<UserControl x:Class="Silverlight20.Control.ToggleButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Left" Width="300">
<!--
Content - ToggleButton上显示的内容
Click - ToggleButton的单击事件
Cursor - 鼠标移动到ToggleButton上面时,鼠标指针的样式
Arrow - 箭头
Hand - 手形
Wait - 沙漏
IBeam - “I”字形
Stylus - 点
Eraser - 橡皮
None - 无
-->
<ToggleButton x:Name="tbtn1" Content="红色的两状态的ToggleButton" Cursor="IBeam" Background="Red" Margin="5" />
<!--
IsThreeState - 是否是 有3个状态 的ToggleButton
false - 通常的两状态。默认值
true - 有3个状态,分别为:true, false, null。也就是说 ToggleButton.IsChecked 是 bool? 类型
Checked - ToggleButton的IsChecked变为true时所触发的事件
Unchecked - ToggleButton的IsChecked变为false时所触发的事件
Indeterminate - ToggleButton的IsChecked变为null时所触发的事件
-->
<ToggleButton x:Name="tbtn2" Content="红色的三状态的ToggleButton" Background="Red" IsThreeState="True" Margin="5" />
<!--
IsEnabled - ToggleButton是否有效
-->
<ToggleButton x:Name="tbtn3" Content="无效的ToggleButton" IsEnabled="False" Margin="5"/>
<!--
ToggleButton.Content - ToggleButton上显示的内容
ClickMode - 触发单击事件的类型 [System.Windows.Controls.ClickMode枚举]
ClickMode.Press - 鼠标左键单击
ClickMode.Release - 鼠标左键单击并放开
ClickMode.Hover - 鼠标经过
-->
<ToggleButton x:Name="tbtn4" ClickMode="Release" Margin="5">
<ToggleButton.Content>
<Image Source="/Silverlight20;component/Images/Logo.jpg" />
</ToggleButton.Content>
</ToggleButton>
<Button Content="各个ToggleButton的选中状态" HorizontalAlignment="Left" Click="Button_Click" Margin="5" />
</StackPanel>
</UserControl>
ToggleButton.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 ToggleButton : UserControl
{
public ToggleButton()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
HtmlWindow html = HtmlPage.Window;
html.Alert(string.Format("tbtn1: {0}rntbtn2: {1}rntbtn3: {2}rntbtn4: {3}",
tbtn1.IsChecked, tbtn2.IsChecked, tbtn3.IsChecked, tbtn4.IsChecked));
}
}
}
OK
Tags:Silverlight 控件 ScrollViewer
编辑录入:爽爽 [复制链接] [打 印]- ››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
- ››Silverlight3系列(四)数据绑定 Data Binding 1
- ››silverlight2 游戏 1 你能坚持多少秒
- ››Silverlight开发实践--PicZoomShow
- 中查找“Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton”更多相关内容
- 中查找“Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton”更多相关内容
- 上一篇:Silverlight(7) - 2.0图形之Ellipse, Line, Path, Polygon, Polyline, Rectangle
- 下一篇:Silverlight(5) - 2.0控件之ListBox, MediaElement, MultiScaleImage, PasswordBox, ProgressBar, RadioButton
更多精彩
赞助商链接