稳扎稳打Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton

稳扎稳打Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton,第1张

概述[索引页] [源码下载] 稳扎稳打Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton 作者: webabcd 介绍 Silverlight 2.0 控件一览:ScrollViewer, Slider, StackPanel, TabControl, [索引页]
[源码下载]


稳扎稳打Silverlight(6) - 2.0控件之ScrollVIEwer,SlIDer,StackPanel,TabControl,TextBlock,TextBox,Togglebutton

作者: webabcd


介绍
Silverlight 2.0 控件一览:ScrollVIEwer,Togglebutton


在线DEMO
http://www.cnblogs.com/webabcd/archive/2008/10/09/1307486.html


示例
1、ScrollVIEwer.xaml

< UserControl  x:Class ="Silverlight20.Control.ScrollVIEwer"

    xmlns
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml/presentation"  

    xmlns:x
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml" >

    
< StackPanel >


        
<!--

        ScrollVIEwer.Content - ScrollVIEwer控件中的内容

        HorizontalScrollbarVisibility - 水平滚动条的显示状态

        VerticalScrollbarVisibility - 垂直滚动条的显示状态

            auto - 自动根据ScrollVIEwer的宽和高,以及内容的宽和高,来决定是否显示滚动条

            Disabled - 不显示,但是可以通过键盘或鼠标在显示内容中的移动或拖动 *** 作,来看到被遮挡的内容

            HIDden - 不显示,而且无法看到被遮挡的内容

            Visible - 显示滚动条

        
-->

        
< ScrollVIEwer  margin ="5"  WIDth ="200"  Height ="200"  HorizontalAlignment ="left"  HorizontalScrollbarVisibility ="auto"  VerticalScrollbarVisibility ="auto" >

            
< ScrollVIEwer.Content >

                
< Image  Source ="/Silverlight20;component/Images/logo.jpg"  WIDth ="300"   />

            
</ ScrollVIEwer.Content >

        
</ ScrollVIEwer >


        
< ScrollVIEwer  margin ="5"  WIDth ="100"  Height ="100"  HorizontalAlignment ="left"  HorizontalScrollbarVisibility ="auto"  VerticalScrollbarVisibility ="auto" >

            
< TextBox >

                
< TextBox.Text >

                    aaa

bbb

ccc

ddd

eee

fff

ggg

hhh

iii

jjj

kkk

lll

mmm

nnn

                
</ TextBox.Text >

            
</ TextBox >

        
</ ScrollVIEwer >


    
</ StackPanel >

</ UserControl >



2、SlIDer.xaml

< UserControl  x:Class ="Silverlight20.Control.SlIDer"

    xmlns
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml/presentation"  

    xmlns:x
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml" >

    
< StackPanel >

                

        
<!--

        Minimum - SlIDer控件的最小值。参见基类System.windows.Controls.Primitives.RangeBase

        Maximum - SlIDer控件的最大值。参见基类System.windows.Controls.Primitives.RangeBase

        Value - SlIDer控件的值。参见基类System.windows.Controls.Primitives.RangeBase

        SmallChange - 按上/下/左/右键的时候,SlIDer 控件的 Value 值的变化跨度。参见 SlIDer 的基类 System.windows.Controls.Primitives.RangeBase

        LargeChange - 鼠标在 SlIDer 上单击的时候,SlIDer 控件的 Value 值的变化跨度。参见 SlIDer 的基类 System.windows.Controls.Primitives.RangeBase

        ValueChanged - SlIDer控件的值发生变化时所触发的事件

        OrIEntation - 控件的放置方向

            Horizontal - 水平放置

            Vertical - 垂直放置

        IsDirectionReversed - 滑块的初始位置

            True - 上到下 或者 右到左

            False - 下到上 或者 左到右

        
-->

        
< SlIDer  Height ="400"  HorizontalAlignment ="left"  OrIEntation ="Vertical"  IsDirectionReversed ="True"  Minimum ="0"  Maximum ="50"  SmallChange ="5"  ValueChanged ="SlIDer_ValueChanged"    />


        
< TextBlock  x:name ="lblMsg"  HorizontalAlignment ="left"   />


    
</ StackPanel >

</ UserControl >



SlIDer.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 SlIDer : UserControl

    

{

        
public SlIDer()

        

{

            InitializeComponent();

        }


        
private voID SlIDer_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)

        

{

            
// RoutedPropertyChangedEventArgs<double>.oldValue - SlIDer控件的原值

            
// RoutedPropertyChangedEventArgs<double>.NewValue - SlIDer控件的新值


            lblMsg.Text 
= string.Format("原值:{0}/r/n新值:{1}", e.oldValue.ToString(), e.NewValue.ToString());

        }

    }

}



3、StackPanel.xaml

< UserControl  x:Class ="Silverlight20.Control.StackPanel"

    xmlns
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml/presentation"  

    xmlns:x
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml" >

    
< StackPanel  HorizontalAlignment ="left" >


        
<!--

        OrIEntation - StackPanel控件内对象的排列方向

            Horizontal - 水平排列

            Vertical - 垂直排列

        
-->

        
< StackPanel  OrIEntation ="Horizontal" >

            
< TextBlock  Text ="a"  margin ="5"   />

            
< TextBlock  Text ="b"  margin ="5"   />

            
< TextBlock  Text ="c"  margin ="5"   />

        
</ StackPanel >

        

        
< StackPanel  OrIEntation ="Vertical" >

            
< TextBlock  Text ="a"  margin ="5"   />

            
< TextBlock  Text ="b"  margin ="5"   />

            
< TextBlock  Text ="c"  margin ="5"   />

        
</ StackPanel >

        

    
</ StackPanel >

</ UserControl >



4、TabControl.xaml

< UserControl  x:Class ="Silverlight20.Control.TabControl"

    xmlns
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml/presentation"  

    xmlns:x
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:basics
="clr-namespace:System.windows.Controls;assembly=System.windows.Controls" >

    
< StackPanel  HorizontalAlignment ="left" >

        

        
<!--

        Selectedindex - 被选中的 TabItem 索引

        SelectedItem - 被选中的 TabItem 对象

        
-->

        
< basics:TabControl  WIDth ="400"  Height ="400"  Selectedindex ="1" >

            

            
< basics:TabItem  header ="Tab1" >

                
< TextBlock  Text ="Tab1 Content"   />

            
</ basics:TabItem >


            
<!--

            TabItem.header - TabItem 的标题

            TabItem.Content - TabItem 的内容

            
-->

            
< basics:TabItem >

                
< basics:TabItem.header >

                    
< TextBlock  Text ="Tab2" />

                
</ basics:TabItem.header >

                
< basics:TabItem.Content >

                    
< TextBlock  Text ="Tab2 Content"   />

                
</ basics:TabItem.Content >

            
</ basics:TabItem >


            
< basics:TabItem >

                
< basics:TabItem.header >

                    
< Image  Source ="/Silverlight20;component/Images/logo.jpg"  Height ="20"   />

                
</ basics:TabItem.header >

                
< TextBlock  Text ="Tab3 Content" ></ TextBlock >

            
</ basics:TabItem >


            
< basics:TabItem >

                
< basics:TabItem.header >

                    
< GrID  WIDth ="100" >

                        
< Image  Source ="/Silverlight20;component/Images/logo.jpg"  Height ="20"  HorizontalAlignment ="Center"   />

                        
< TextBlock  Text ="Tab4"  HorizontalAlignment ="Center"   />

                    
</ GrID >

                
</ basics:TabItem.header >

                
< TextBlock  Text ="Tab4 Content" ></ TextBlock >

            
</ basics:TabItem >

            

        
</ basics:TabControl >

        

    
</ StackPanel >

</ UserControl >



5、TextBlock.xaml

< UserControl  x:Class ="Silverlight20.Control.TextBlock"

    xmlns
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml/presentation"  

    xmlns:x
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml" >

    
< StackPanel  HorizontalAlignment ="left" >


        
<!--

        Text - TextBlock上显示的值

        
-->

        
< TextBlock  Text ="TextBlock"   />


        
<!--

        Foreground - 字体颜色

        
-->

        
< TextBlock  Text ="红色的TextBlock"  Foreground ="Red"   />


        
<!--

        要以XAML的方式直接显示引号等特殊字请使用相应的HTML编码

        
-->

        
< TextBlock  Text ="带引号的&quot;TextBlock&quot;"   />


        
<!--

        FontFamily - 字体

        FontSize - 字体大小

        FontWeight - 字形粗细度 [System.windows.FontWeights枚举]

        FontStyle - 字形斜体否 [System.windows.FontStyles枚举]

        Textdecorations - 字体下划线 [System.windows.Textdecorations枚举]

        FontStretch - 字体间距 [System.windows.FontStretches枚举]

        
-->

        
< TextBlock  Text ="常用属性TextBlock"  FontFamily ="宋体"  FontSize ="36"  FontWeight ="Bold"  FontStyle ="Italic"  Textdecorations ="Underline"  FontStretch ="normal"   />


        
<!--

        TextAlignment - 文字排列 [System.windows.TextAlignment枚举]

        Run - 文本内容

        lineBreak - 换行符

        lineHeight - 每行行高

        textwrapPing - 文本限制(超过限制是否换行)

            nowrap - 永不换行

            Wrap - 超过限制则换行

        linestackingStrategy - 控制行高的策略

            MaxHeight - TextBlock内每行的行高 以lineHeight值 和 每行自身所设置的行高值 间的最大值为准

            BlocklineHeight - TextBlock内每行的行高 以lineHeight值为准

        
-->

        
< TextBlock  VerticalAlignment ="Center"  TextAlignment ="Center"  lineHeight ="10"  linestackingStrategy ="MaxHeight"  WIDth ="200"  textwrapPing ="nowrap" >

            
< Run  FontSize ="20"  Foreground ="Maroon"  Text ="MaroonMaroonMaroonMaroon"   />

            
< lineBreak />

            
< Run  Foreground ="teal"  Text ="teal"   />

            
< lineBreak />

            
< Run  FontSize ="30"  Foreground ="SteelBlue"  Text ="SteelBlue"   />

        
</ TextBlock >


        

        
< TextBlock  VerticalAlignment ="Center"  TextAlignment ="Center"  lineHeight ="10"  linestackingStrategy ="BlocklineHeight"  WIDth ="200"  textwrapPing ="Wrap" >

            
< Run  FontSize ="20"  Foreground ="Red"  Text ="RedRedRedRedRedRedRedRedRed"   />

            
< lineBreak />

            
< Run  Foreground ="Green"  Text ="Green"   />

            
< lineBreak />

            
< Run  FontSize ="30"  Foreground ="Blue"  Text ="Blue"   />

        
</ TextBlock >

       

    
</ StackPanel >

</ UserControl >



6、TextBox.xaml

< UserControl  x:Class ="Silverlight20.Control.TextBox"

    xmlns
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml/presentation"  

    xmlns:x
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml" >

    
< StackPanel  HorizontalAlignment ="left"  WIDth ="200" >


        
<!--

        Text - TextBox内显示的值

        borderThickness - 边框的宽度(像素值:上下左右;左右,上下;左,上,右,下)

        borderBrush - 边框的颜色

        
-->

        
< TextBox  Text ="红色框绿色底蓝色字(真难看)"  borderBrush ="Red"  borderThickness ="1,5"  Background ="Green"  Foreground ="Blue"  margin ="6"   />

                

        
<!--

        IsReadonly - 是否只读

        
-->

        
< TextBox  Text ="只读TextBox"  IsReadonly ="True"  margin ="6"   />

        

        
<!--

        AcceptsReturn - 是否允许输入回车

        HorizontalScrollbarVisibility - 水平滚动条的显示状态

        VerticalScrollbarVisibility - 垂直滚动条的显示状态

            auto - 自动根据TextBox控件的宽和高,以及其内容的宽和高,来决定是否显示滚动条

            Disabled - 不显示,但是可以通过键盘或鼠标在显示内容中的移动或拖动 *** 作,来看到被遮挡的内容

            HIDden - 不显示,而且无法看到被遮挡的内容

            Visible - 显示滚动条

        
-->

        
< TextBox  Height ="50"  AcceptsReturn ="True"  VerticalScrollbarVisibility ="auto"  margin ="6"

                Text
="多行文本框1 多行文本框2 多行文本框3 多行文本框4 多行文本框5 多行文本框6"   />

        

        
<!--

        SelectionChanged - 选中的文本内容发生变化时所触发的事件

        
-->

        
< TextBox  Height ="50"  AcceptsReturn ="False"  margin ="5"  SelectionChanged ="TextBox_SelectionChanged"

                Text
="相应选中事件多行文本框1 多行文本框2 多行文本框3"   />

        

        
< TextBlock  margin ="5" >

            
< Run > 选中的文本为: </ Run >

            
< lineBreak  />

            
< Run  x:name ="lblMsg" ></ Run >

        
</ TextBlock >

        

    
</ StackPanel >

</ UserControl >


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
="@R_502_6822@://schemas.microsoft.com/winfx/2006/xaml/presentation"  

    xmlns:x
="@R_502_6822@://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}/r/ntbtn2: {1}/r/ntbtn3: {2}/r/ntbtn4: {3}",

                tbtn1.IsChecked, tbtn2.IsChecked, tbtn3.IsChecked, tbtn4.IsChecked));

        }

    }

}



OK
[源码下载] @H_301_3967@ 总结

以上是内存溢出为你收集整理的稳扎稳打Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton全部内容,希望文章能够帮你解决稳扎稳打Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1053661.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存