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

[索引页]
[源码下载]


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


作者: webabcd


介绍
Silverlight 2.0 控件一览:ScrollViewer, Slider, StackPanel, TabControl, TextBlock, TextBox, ToggleButton 


在线DEMO
http://webabcd.blog.51cto.com/1787395/342779


示例
1、ScrollViewer.xaml
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
         

                 
                 
                         
                                 
                        
 
                
 

                 
                         
                                 
                                        aaa 
bbb 
ccc 
ddd 
eee 
fff 
ggg 
hhh 
iii 
jjj 
kkk 
lll 
mmm 
nnn 
                                
 
                        
 
                
 

        
 
 
 
2、Slider.xaml
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
         
                                 
                 
                 

                 

        
 
 
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.OldValue - Slider控件的原值 
                         // RoutedPropertyChangedEventArgs.NewValue - Slider控件的新值 
 
                        lblMsg.Text =  string.Format( "原值:{0}\r\n新值:{1}", e.OldValue.ToString(), e.NewValue.ToString()); 
                } 
        } 
}
 
 
3、StackPanel.xaml
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
         

                 
                 
                         
                         
                         
                
 
                 
                 
                         
                         
                         
                
 
                 
        
 
 
 
4、TabControl.xaml
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"> 
         
                 
                 
                 
                         
                         
                                 
                        
 

                         
                         
                                 
                                         
                                
 
                                 
                                         
                                
 
                        
 

                         
                                 
                                         
                                
 
                                 
                        
 

                         
                                 
                                         
                                                 
                                                 
                                        
 
                                
 
                                 
                        
 
                         
                
 
                 
        
 
 
 
5、TextBlock.xaml
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
         

                 
                 

                 
                 

                 
                 

                 
                 

                 
                 
                         
                         
                         
                         
                         
                
 

                 
                 
                         
                         
                         
                         
                         
                
 
                
        
 
 
 
6、TextBox.xaml
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
         

                 
                 
                                 
                 
                 
                 
                 
                                                 Text="多行文本框1 多行文本框2 多行文本框3 多行文本框4 多行文本框5 多行文本框6" /> 
                 
                 
                                                 Text="相应选中事件多行文本框1 多行文本框2 多行文本框3" /> 
                 
                 
                        选中的文本为: 
                         
                         
                
 
                 
        
 
 
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
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
         

                 
                 

                 
                 

                 
                 

                 
                 
                         
                                 
                        
 
                
 

                
 
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
[源码下载]
 




     本文转自webabcd 51CTO博客,原文链接:http://blog.51cto.com/webabcd/342829 ,如需转载请自行联系原作者

你可能感兴趣的:(稳扎稳打Silverlight(6) - 2.0控件之ScrollViewer, Slider, StackPanel, TabControl, TextBlock)