ylbtech-SilverLight-Basic-Control:基础控件使用(1)

本文详解控件有:

Label, TextBox, PasswordBox, Image, Button

, RadioButton, CheckBox, TextBlock

1.A,返回顶部 Label(标签)
1,

<dataInput:Label Height="20" HorizontalAlignment="Left" Margin="58,61,0,0"
Name="label1" VerticalAlignment="Top" Width="50" Content="姓名" />

2,Name,Height,Width,

Content[内容【显示文本】]

3,

label1.Content = "赋值";
string str = label1.Content.ToString(); //取值

4,

1.B,返回顶部 TextBox(文本框)
1,

<TextBox DataContext="{Binding}" Height="23" HorizontalAlignment="Left" Margin="10,10,0,0"
MaxLength="10" Name="textBox1" Text="请输入您的姓名" VerticalAlignment="Top" Width="120" />

2,Name,Height,Width,

Text,MaxLength

3,

 textBox1.Text = "赋值";
string str = textBox1.Text; //取值

4,

1.C,返回顶部 PasswordBox(密码框)
1,

<PasswordBox Height="23" HorizontalAlignment="Left" Margin="30,70,0,0"
Name="passwordBox1" VerticalAlignment="Top" Width="120"
Password="123456" PasswordChar="*" MaxLength="20" />

2,Name,Height,Width,

Password[密码],PasswordChar[掩饰字符],MaxLength

3,

passwordBox1.Password = "";   //赋值
string str = passwordBox1.Password; //取值
1.D,返回顶部 Image(图片)
1,

<Image Height="150" HorizontalAlignment="Left" Margin="151,117,0,0"
Name="image1" Stretch="Uniform" VerticalAlignment="Top" Width="200"
Source="/SilverlightApplication3;component/Images/img.jpg" />

2,Name,Height,Width,

Stretch[拉伸方式],Source[图片资源路径]

3,无
4,
1.E,返回顶部 Button(按钮)
1,

<Button Content="按钮名称" Height="23" HorizontalAlignment="Left" Margin="13,41,0,0"
Name="button1" VerticalAlignment="Top" Width="75" />

2,Name,Height,Width,

Content

3,

button1.Content = "按钮名称";   //赋值
string str = button1.Content.ToString(); //取值

4,Event

4.1/2,Click

<TextBox DataContext="{Binding}" Height="23" HorizontalAlignment="Left" Margin="10,10,0,0"
MaxLength="10" Name="textBox1" Text="" VerticalAlignment="Top" Width="120" />
<Button Content="按钮名称" Height="23" HorizontalAlignment="Left" Margin="13,41,0,0"
Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<dataInput:Label Height="18" HorizontalAlignment="Left" Margin="14,74,0,0"
Name="label1" VerticalAlignment="Top" Width="100" />

4.2/2,

private void button1_Click(object sender, RoutedEventArgs e)
{
//按钮单击事件
label1.Content = textBox1.Text;
}

5,

1.F,返回顶部 RadioButton(单选按钮)
1,

 <RadioButton Content="男" Height="16" HorizontalAlignment="Left" Margin="21,111,0,0"
Name="radioButton1" VerticalAlignment="Top" GroupName="sex" IsChecked="True" />
<RadioButton Content="女" Height="16" HorizontalAlignment="Left" Margin="66,111,0,0"
Name="radioButton2" VerticalAlignment="Top" GroupName="sex" />

2,Name,Height,Width,

Content,GroupName[同一组名称相同],IsChecked

3,

//赋值
radioButton1.Content = "女女";
radioButton1.IsChecked = true;
radioButton1.GroupName = "sex";
radioButton2.Content = "男男";
radioButton2.GroupName = "sex";
//取值
string sex = string.Empty;
if (radioButton1.IsChecked==true)
{
sex = radioButton1.Content.ToString();
}
else if (radioButton2.IsChecked == true)
{
sex = radioButton2.Content.ToString();
}

4,

1.G,返回顶部 CheckBox(复选框)
1,

 <CheckBox Content="篮球" Height="16" HorizontalAlignment="Left" Margin="53,81,0,0"
Name="checkBox1" VerticalAlignment="Top" IsChecked="True" />
<CheckBox Content="足球" Height="16" HorizontalAlignment="Right" Margin="0,81,256,0"
Name="checkBox2" VerticalAlignment="Top" />
<CheckBox Content="羽毛球" Height="16" HorizontalAlignment="Right" Margin="0,81,197,0"
Name="checkBox3" VerticalAlignment="Top" />

2,Name,Height,WIdth,

Content,IsChecked

3,

//赋值
checkBox1.Content = "basketball";
checkBox1.IsChecked = true; //设为默认选项
checkBox2.Content = "football";
checkBox3.Content = "badminton";
checkBox3.IsChecked = true; //设为默认选项
//取值
string balls = string.Empty;
if (checkBox1.IsChecked == true)
{
balls += checkBox1.Content+",";
}
if (checkBox2.IsChecked == true)
{
balls += checkBox2.Content + ",";
}
if (checkBox3.IsChecked == true)
{
balls += checkBox3.Content + ",";
}

4,

1.H,返回顶部 TextBlock(文本框)
1,
1.1/2,

<TextBlock Height="63" Name="textBlock1"
Text="《静夜思》李白 窗前明月光,疑是地上霜。举头望明月,低头思故乡。"
Width="172" TextWrapping="Wrap" />

1.2/2,

<TextBlock Height="152" Name="textBlock1" Width="172" TextWrapping="Wrap" >
<Run FontWeight="Bold">《静夜思》</Run>
<Run FontSize="10">李白</Run>
<LineBreak/>
窗前明月光,<LineBreak/>
疑是地上霜。<LineBreak/>
<Run FontSize="25" Foreground="Red">举头望明月,</Run> <LineBreak/>
低头思故乡。<LineBreak/>
</TextBlock>

2,Name,Height,Width,

Text,TextWrapping[是否允许换行]
3,

//赋值
textBlock1.Text = "后台赋值";
//取值
string str = textBlock1.Text;

4,

1.R,返回顶部
 
作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

SilverLight:基础控件使用(1)的更多相关文章

  1. SilverLight:基础控件使用(6)-Slider控件

    ylbtech-SilverLight-Basic-Control:基础控件使用(6)-Slider控件 Slider 控件 Slider 控件的 ValueChanged 事件 1.A,返回顶部 S ...

  2. SilverLight:基础控件使用(5)-TreeView控件-基本使用

    ylbtech-SilverLight-Basic-Control:基础控件使用(5)-TreeView控件-基本使用 前台编辑 后台逐个添加 后台绑定数据源 1.A,返回顶部TreeView控件(树 ...

  3. SilverLight:基础控件使用(4)-日期显示和选择类控件

    ylbtech-SilverLight-Basic-Control:基础控件使用(4)-日期显示和选择类控件 Calendar,DatePicker 1.A,返回顶部 Calendar控件(日期控件) ...

  4. SilverLight:基础控件使用(3)-DataGrid控件

    ylbtech-SilverLight-Basic-Control:基础控件使用(3)-DataGrid控件 DataGrid控件-后台绑定 自动生成表列 不自动生成表列 1.A,返回顶部Person ...

  5. SilverLight:基础控件使用(2)-ComboBox,ListBox控件

    ylbtech-SilverLight-Basic-Control:基础控件使用(2)-ComboBox,ListBox控件 直接在 XAML 代码中设置 Items 和通过后台代码绑定数据源 Com ...

  6. React Native环境搭建以及几个基础控件的使用

    之前写了几篇博客,但是没有从最基础的开始写,现在想了想感觉不太合适,所以现在把基础的一些东西给补上,也算是我从零开始学习RN的经验吧! 一.环境搭建 首先声明一下,本人现在用的编辑器是SublimeT ...

  7. Cocos2d-JS项目之二:studio基础控件的使用

    在studio里把几个基础控件往场景文件一拖,然后导出json格式的资源文件 逻辑代码如下: var HelloWorldLayer = cc.Layer.extend({ sprite:null, ...

  8. [iOS基础控件 - 5.5] 代理设计模式 (基于”APP列表"练习)

    A.概述      在"[iOS基础控件 - 4.4] APP列表 进一步封装,初见MVC模式”上进一步改进,给“下载”按钮加上效果.功能      1.按钮点击后,显示为“已下载”,并且不 ...

  9. javascript实现silverlight pivotViewer控件

    一时无事,就用js实现了一个silverlight pivotViewer控件来练手. 实现效果: silverlight PivotViewer说明地址:https://msdn.microsoft ...

随机推荐

  1. CodeForces 519E 树形DP A and B and Lecture Rooms

    给出一棵树,有若干次询问,每次询问距两个点u, v距离相等的点的个数. 情况还挺多的,少侠不妨去看官方题解.^_^ #include <iostream> #include <cst ...

  2. Android工具 Hierarchy Viewer 分析

    Hierarchy Viewer是随AndroidSDK发布的工具,位置在tools文件夹下,名为hierarchyviewer.bat.它是Android自带的非常有用而且使用简单的工具,可以帮助我 ...

  3. Huawei比赛数据分析

    如何评价2018年华为软件精英挑战赛赛题? https://www.zhihu.com/question/268448695 1.时间与时间戳之间的转换 https://blog.csdn.net/g ...

  4. Spring-Boot自定义Starter实践

    此文已由作者王慎为授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. disconf-spring-boot-starter 使用方法: 引入maven依赖: <depen ...

  5. 理一理Spring如何对接JUnit

    测试代码 package org.simonme.srcstudy.spring3.demo.stub; import static org.junit.Assert.assertNotNull; i ...

  6. django html render_to_response

    #coding=utf-8 from django.shortcuts import render from blog.models import BlogPost from django.short ...

  7. c/c++内存泄露的检测方法

    此文内容摘自 https://zhuanlan.zhihu.com/p/22664202 作为   从零开始的 JSON 库教程(三):解析字符串解答篇  的笔记 1A. Windows 下的内存泄漏 ...

  8. WTForms 表单动态验证

    class UserDetails(Form): group_id = SelectField(u'Group', coerce=int) def edit_user(request, id): us ...

  9. 【Luogu】P3806点分治模板(点分治)

    题目链接 wc听不懂lca讲的高等数学专场(一个字都听不懂),然后就自学了点分治. 点分治就是我先处理完跟根有关的东西,然后把根标记掉,把原树拆成若干个联通块,然后分别对每个联通块(每个小树)搞一模一 ...

  10. [CODEVS1915] 分配问题(最小费用最大流)

    传送门 脑残题 建图都懒得说了 ——代码 #include <queue> #include <cstdio> #include <cstring> #includ ...