稳扎稳打Silverlight(4) - 2.0控件之DataGrid, DatePicker, Grid, GridSplitter, HyperlinkButton, Image

[索引页]
[源码下载]


稳扎稳打Silverlight(4) - 2.0控件之DataGrid, DatePicker, Grid, GridSplitter, HyperlinkButton, Image


作者: webabcd


介绍
Silverlight 2.0 控件一览:DataGrid, DatePicker, Grid, GridSplitter, HyperlinkButton, Image


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


示例
1、DataGrid.xaml
< UserControl  xmlns:data ="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"   x:Class ="Silverlight20.Control.DataGrid"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml" >
    
< StackPanel  HorizontalAlignment ="Left" >
        
        
<!--
        后台邦定方式,自动生成列
        
-->
        
< data:DataGrid  x:Name ="dgrd"  AutoGenerateColumns ="True" ></ data:DataGrid >
        
    
</ StackPanel >
</ UserControl >

DataGrid.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 DataGrid : UserControl
    
{
        
public DataGrid()
        
{
            InitializeComponent();

            BindData();
        }


        
void BindData()
        
{
            var source 
= new Data.SourceData();

            
// 设置 DataGrid 的数据源
            dgrd.ItemsSource = source.GetData().Take(10);
        }

    }

}



2、DatePicker.xaml
< UserControl  x:Class ="Silverlight20.Control.DatePicker"
    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" >
    
< StackPanel  HorizontalAlignment ="Left" >
        
        
<!--
        TextBox 结合 Calendar,经典的选择日期的方式
        SelectedDateFormat - 被选中的日期的显示格式 [System.Windows.Controls.DatePickerFormat枚举]
            SelectedDateFormat.Short - 简短格式。默认值。如2008-10-10
            SelectedDateFormat.Long - 非简短格式。如2008年10月10日
        
-->
        
< basics:DatePicker  Width ="200"  SelectedDateFormat ="Short" ></ basics:DatePicker >
        
    
</ StackPanel >
</ UserControl >


3、Grid.xaml
< UserControl  x:Class ="Silverlight20.Control.Grid"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"  
    Width
="Auto"  Height ="500" >
    
    
<!--
    Grid - 表格式布局模式
        Grid.RowDefinitions - 用于定义 Grid 中的行
        Grid.ColumnDefinitions - 用于定义 Grid 中的列
        Grid.ShowGridLines - 显示网格
    
        Grid.Row - 控件所在的 Grid 的行的索引
        Grid.Column - 控件所在的 Grid 的列的索引
        Grid.RowSpan - 合并行。 控件所在行,以及控件所在行之后的需要连续合并的行的总行数
        Grid.ColumnSpan - 合并列。 控件所在列,以及控件所在列之后的需要连续合并的列的总列数
    
        Width - 宽度
        MinWidth - 最小宽度
        MaxWidth - 最大宽度
        Height - 高度
        MinHeight - 最小高度
        MaxHeight - 最大高度
    
    Width 和 Height 的可用值
    Auto - 自动设置为一个合适的值。默认值
    Pixel - 像素值
    * - 比例值。如 * 就是全部,2* & 8* 就是分别占20%和80%
    
-->
    
< Grid  x:Name ="LayoutRoot"  Background ="White"  ShowGridLines ="True" >
        
        
< Grid.RowDefinitions >
            
< RowDefinition  Height ="50"   />
            
< RowDefinition  Height ="3*"   />
            
< RowDefinition  Height ="7*"   />
            
< RowDefinition  Height ="*"  MinHeight ="200"  MaxHeight ="500"   />
            
< RowDefinition  Height ="Auto"   />
        
</ Grid.RowDefinitions >
        
        
< Grid.ColumnDefinitions >
            
< ColumnDefinition  />
            
< ColumnDefinition  />
            
< ColumnDefinition  />
        
</ Grid.ColumnDefinitions >
        
        
< TextBox  Grid.Row ="0"  Grid.Column ="0"  Background ="red"  Text ="abc"   />
        
< TextBox  Grid.Row ="0"  Grid.Column ="1"  Background ="red"  Text ="abc"  Grid.ColumnSpan ="2"  HorizontalAlignment ="Center"   />
        
< TextBox  Grid.Row ="1"  Grid.Column ="0"  Background ="red"  Text ="abc"   />
        
< TextBox  Grid.Row ="1"  Grid.Column ="1"  Background ="red"  Text ="abc"  Grid.ColumnSpan ="2"  HorizontalAlignment ="Center"   />
        
< TextBox  Grid.Row ="2"  Grid.Column ="0"  Background ="red"  Text ="abc"   />
        
< TextBox  Grid.Row ="2"  Grid.Column ="1"  Background ="red"  Text ="abc"  Grid.RowSpan ="2"  VerticalAlignment ="Bottom"   />
        
< TextBox  Grid.Row ="2"  Grid.Column ="2"  Background ="red"  Text ="abc"   />
        
< TextBox  Grid.Row ="3"  Grid.Column ="2"  Background ="red"  Text ="abc"   />
        
< TextBox  Grid.Row ="4"  Grid.Column ="2"  Background ="red"  Text ="abc"   />
        
    
</ Grid >
    
</ UserControl >


4、GridSplitter.xaml
< UserControl  x:Class ="Silverlight20.Control.GridSplitter"
    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" >
    
< Grid  x:Name ="LayoutRoot"  Background ="White" >
        
        
< Grid.RowDefinitions >
            
< RowDefinition  Height ="100"   />
            
< RowDefinition  Height ="5"   />
            
< RowDefinition  Height ="100"   />
        
</ Grid.RowDefinitions >
        
        
< Grid.ColumnDefinitions >
            
< ColumnDefinition  Width ="100"   />
            
< ColumnDefinition  Width ="5"   />
            
< ColumnDefinition  Width ="100"   />
        
</ Grid.ColumnDefinitions >
        
        
< Rectangle  Grid.Row ="0"  Grid.Column ="0"  Fill ="Red" />
        
< Rectangle  Grid.Row ="0"  Grid.Column ="2"  Fill ="Green"   />
        
< Rectangle  Grid.Row ="2"  Grid.Column ="0"  Fill ="Blue"   />
        
< Rectangle   Grid.Row ="2"  Grid.Column ="2"  Fill ="Yellow"   />
        
        
<!--
        ShowsPreview - 拖动 GridSplitter 时,是要即时显示拖动结果(false 默认值),还是要先预览GridSplitter被拖动的位置(true)
        
-->
        
< basics:GridSplitter  Grid.Row ="1"  Grid.Column ="0"  Grid.ColumnSpan ="3"  ShowsPreview ="True"  HorizontalAlignment ="Stretch"  VerticalAlignment ="Stretch"   />
        
< basics:GridSplitter  Grid.Row ="0"  Grid.Column ="1"  Grid.RowSpan ="3"  HorizontalAlignment ="Stretch"  VerticalAlignment ="Stretch"   />
        
    
</ Grid >
</ UserControl >


5、HyperlinkButton.xaml
< UserControl  x:Class ="Silverlight20.Control.HyperlinkButton"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml" >
    
< StackPanel  HorizontalAlignment ="Left" >

        
<!--
        NavigateUri - 超级链接的目标地址
        TargetName - 目标名
        
-->
        
< HyperlinkButton  Content ="http://webabcd.cnblogs.com"  NavigateUri ="http://webabcd.cnblogs.com/"  HorizontalContentAlignment ="Center"  TargetName ="_blank"  Background ="Black"  Foreground ="White"  Margin ="5"  Width ="200"   />

        
<!--
        HyperlinkButton.Content - 超级链接所显示的内容
        
-->
        
< HyperlinkButton  NavigateUri ="http://webabcd.cnblogs.com/"  TargetName ="_blank"  Margin ="5"  Width ="200" >
            
< HyperlinkButton.Content >
                
< Image  Source ="/Silverlight20;component/Images/Logo.jpg"   />
            
</ HyperlinkButton.Content >
        
</ HyperlinkButton >

    
</ StackPanel >
</ UserControl >


6、Image.xaml
< UserControl  x:Class ="Silverlight20.Control.Image"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml" >
    
< StackPanel  HorizontalAlignment ="Left" >
        
        
<!--
        Source - 程序目录下的图片文件地址
        
-->
        
< Image  Source ="/Logo.jpg"  Margin ="5"  Width ="100"    />
        
        
<!--
        Source - 程序集内的图片文件地址 [/程序集名;component/图片路径]
        
-->
        
< Image  Source ="/Silverlight20;component/Images/Logo.jpg"  Margin ="5"  Width ="200"   />

        
<!--
        Source - 互联网的图片文件地址
        
-->
        
< Image  Source ="http://silverlight.net/Themes/silverlight/images/logo.jpg"  Margin ="5"  Width ="100"   />

        
<!--
        Source - 后台方式设置Image的Source
        
-->
        
< Image  x:Name ="img"  Margin ="5"  Width ="100"   />
        
< Image  x:Name ="img2"  Margin ="5"  Width ="100"   />

    
</ StackPanel >
</ UserControl >

Image.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.Media.Imaging;
using  System.Windows.Resources;

namespace  Silverlight20.Control
{
    
public partial class Image : UserControl
    
{
        
public Image()
        
{
            InitializeComponent();

            
// 后台方式设置Image的Source
            img.Source = new BitmapImage(new Uri("/Silverlight20;component/Images/Logo.jpg", UriKind.Relative));

            StreamResourceInfo sri 
= Application.GetResourceStream(
                
new Uri("/Silverlight20;component/Images/Logo.jpg", UriKind.Relative));
            BitmapImage imageSource 
= new BitmapImage();
            imageSource.SetSource(sri.Stream);
            img2.Source 
= imageSource;
        }

    }

}



OK
[源码下载]
课程设计报告:总体方案设计说明 一、软件开发环境配置 本系统采用C++作为核心编程语言,结合Qt 5.12.7框架进行图形用户界面开发。数据库管理系统选用MySQL,用于存储用户数据与小精灵信息。集成开发环境为Qt Creator,操作系统平台为Windows 10。 二、窗口界面架构设计 系统界面由多个功能模块构成,各模块职责明确,具体如下: 1. 起始界面模块(Widget) 作为应用程序的入口界面,提供初始导航功能。 2. 身份验证模块(Login) 负责处理用户登录与账户注册流程,实现身份认证机制。 3. 游戏主大厅模块(Lobby) 作为用户登录后的核心交互区域,集成各项功能入口。 4. 资源管理模块(BagWidget) 展示用户持有的全部小精灵资产,提供可视化资源管理界面。 5. 精灵详情模块(SpiritInfo) 呈现选定小精灵的完整属性数据与状态信息。 6. 用户名录模块(UserList) 系统内所有注册用户的基本信息列表展示界面。 7. 个人资料模块(UserInfo) 显示当前用户的详细账户资料与历史数据统计。 8. 服务器精灵选择模块(Choose) 对战准备阶段,从服务器可用精灵池中选取参战单位的专用界面。 9. 玩家精灵选择模块(Choose2) 对战准备阶段,从玩家自有精灵库中筛选参战单位的操作界面。 10. 对战演算模块(FightWidget) 实时模拟精灵对战过程,动态呈现战斗动画与状态变化。 11. 对战结算模块(ResultWidget) 对战结束后,系统生成并展示战斗结果报告与数据统计。 各模块通过统一的事件驱动机制实现数据通信与状态同步,确保系统功能的连贯性与数据一致性。界面布局遵循模块化设计原则,采用响应式视觉方案适配不同显示环境。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值