码迷,mamicode.com
首页 > Web开发 > 详细

silverlight 生成二维码

时间:2014-07-29 10:25:38      阅读:338      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   art   div   

MainPage.xaml

bubuko.com,布布扣
 1  <Grid x:Name="LayoutRoot" Background="White">
 2         <Border BorderThickness="2" BorderBrush="Black" />
 3         <Grid ShowGridLines="True">
 4             <Grid.RowDefinitions>
 5                 <RowDefinition/>
 6                 <RowDefinition Height="50"/>
 7                 <RowDefinition Height="50"/>
 8                 <RowDefinition Height="50"/>
 9             </Grid.RowDefinitions>
10             <Grid.ColumnDefinitions>
11                 <ColumnDefinition Width="100"/>
12                 <ColumnDefinition/>
13             </Grid.ColumnDefinitions>
14             <TextBlock Text="二维码" Grid.Column="0" Grid.Row="0" TextAlignment="Center" Margin="10,50" />
15             <Image x:Name="imgCode" Grid.Column="1" Grid.Row="0" Margin="2"/>
16             <TextBlock Text="图片大小" Grid.Column="0" Grid.Row="1" Margin="10" TextAlignment="Center" />
17             <ComboBox x:Name="cmbSize" Grid.Column="1" Grid.Row="1" Width="100" Height="30" HorizontalAlignment="Right" Margin="0,10,100,10">
18                 <ComboBoxItem Content="100" IsSelected="True" />
19                 <ComboBoxItem Content="150" />
20             </ComboBox>
21             <TextBlock Text="二维码内容" Grid.Column="0" Grid.Row="2" TextAlignment="Center" Margin="10"/>
22             <TextBox x:Name="txtContent" Height="30" Margin="5" Grid.Column="1" Grid.Row="2" />
23             <Button x:Name="btnAdd" Content="生成" Width="100"  Grid.Row="3" Grid.Column="1" Click="btnAdd_Click" Margin="5"/>
24         </Grid>
25     </Grid>
View Code

MainPage.xaml.cs

bubuko.com,布布扣
 1  public partial class MainPage : UserControl
 2     {
 3         StringBuilder sb = null;
 4         Uri uri = null;
 5         public MainPage()
 6         {
 7             InitializeComponent();
 8             sb = new StringBuilder();
 9         }
10         private void btnAdd_Click(object sender, RoutedEventArgs e)
11         {
12             sb.Append("http://chart.apis.google.com/chart?cht=qr&chs=");
13             sb.Append(((ComboBoxItem)cmbSize.SelectedItem).Content.ToString());
14             sb.Append("x");
15             sb.Append(((ComboBoxItem)cmbSize.SelectedItem).Content.ToString());
16             sb.Append("&chl=");
17             sb.Append(txtContent.Text);
18             uri = new Uri(sb.ToString());
19             imgCode.Source = new BitmapImage(uri);
20             sb.Clear();
21         }
22     }
View Code

 

silverlight 生成二维码,布布扣,bubuko.com

silverlight 生成二维码

标签:style   blog   http   color   os   io   art   div   

原文地址:http://www.cnblogs.com/zxbzl/p/3873668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!