SilverLight:基础控件使用(1)_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > SilverLight:基础控件使用(1)

SilverLight:基础控件使用(1)

 2013/10/30 16:13:10  ylbtech  博客园  我要评论(0)
  • 摘要:ylbtech-SilverLight-Basic-Control:基础控件使用(1)本文详解控件有:Label,TextBox,PasswordBox,Image,Button,RadioButton,CheckBox,TextBlock1.A,返回顶部Label(标签)1,<dataInput:LabelHeight="20"HorizontalAlignment="Left"Margin="58,61,0
  • 标签:Silverlight 使用 控件
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 = "123456";   //赋值
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,返回顶部   warn 作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
发表评论
用户名: 匿名