silverlight 產生二維碼

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   io   art   div   

MainPage.xaml

 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

 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

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.