第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問如何在運行時將圖像加載到WPF?

請問如何在運行時將圖像加載到WPF?

C#
翻翻過去那場雪 2019-12-02 08:04:02
如何在運行時將圖像加載到WPF?經過一些搜索,將運行時的圖像加載到WPF窗口似乎相當復雜!        Image image;         image = new Uri("Bilder/sas.png", UriKind.Relative);         ????.Source = new BitmapImage(image);我正在嘗試使用此代碼,但我需要一些幫助才能使其正常工作。我在代碼下面有一些紅線!我也想知道是否需要在XAML代碼中添加一些額外的代碼,或者是否足夠了: <Image Height="200" HorizontalAlignment="Left" Margin="12,12,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="350" />不知道,因為我看過XAML標簽內部圖像的示例。編輯:我知道這個:        var uri = new Uri("pack://application:,,,/sas.png");         var bitmap = new BitmapImage(uri);         image1.Source = bitmap;XAML:    <Grid Width="374">     <Image Height="200" HorizontalAlignment="Left" Margin="12,12,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="350" />     <Button Content="Start" Height="23" HorizontalAlignment="Left" Margin="12,226,0,0" Name="btnStart" VerticalAlignment="Top" Width="75" />     <Button Content="Land" Height="23" HorizontalAlignment="Left" Margin="287,226,0,0" Name="btnLand" VerticalAlignment="Top" Width="75" />     <ComboBox Height="23" HorizontalAlignment="Left" Margin="110,226,0,0" Name="cmbChangeRoute" VerticalAlignment="Top" Width="156" /></Grid>編輯2:我的答案是“解決”,但在Stack Overflow之外的som幫助。這段代碼工作正常:        BitmapImage image = new BitmapImage();         image.BeginInit();         image.UriSource = new Uri("pack://application:,,,/Resources/" + company + ".png");         image.EndInit();         image2.Source = image;
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 525 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號