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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何使用Properties.Resources中的圖像從WPF中的代碼隱藏動(dòng)態(tài)更改圖像源?

如何使用Properties.Resources中的圖像從WPF中的代碼隱藏動(dòng)態(tài)更改圖像源?

如何使用Properties.Resources中的圖像從WPF中的代碼隱藏動(dòng)態(tài)更改圖像源?我有一個(gè)WPF應(yīng)用程序,需要向用戶提供有關(guān)內(nèi)部狀態(tài)的反饋。設(shè)計(jì)是有三個(gè)圖像,稱為紅色,黃色和綠色。其中一個(gè)圖像將根據(jù)狀態(tài)一次顯示。以下是要點(diǎn):這三個(gè)圖像位于代碼隱藏中的Properties.Resources中一次只能顯示一個(gè)圖像。狀態(tài)更改來自代碼隱藏中的進(jìn)程,而不是來自用戶。我想綁定一個(gè)圖像控件,以便我可以從代碼隱藏更改圖像。我假設(shè)我需要一個(gè)圖像轉(zhuǎn)換器來將JPG圖像更改為圖像源,例如:[ValueConversion(typeof(System.Drawing.Bitmap), typeof(ImageSource))]public class BitmapToImageSourceConverter : IValueConverter{     public object Convert(object value, Type targetType, object parameter, CultureInfo culture)     {         var bmp = value as System.Drawing.Bitmap;         if (bmp == null)             return null;         return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(                     bmp.GetHbitmap(),                     IntPtr.Zero,                     Int32Rect.Empty,                     BitmapSizeOptions.FromEmptyOptions());     }     public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)     {         throw new NotSupportedException();     }}我更喜歡在初始化期間轉(zhuǎn)換圖像一次并保留圖像源列表。我還假設(shè)我需要一個(gè)依賴屬性來綁定控件,但我不知道如何使用這個(gè)圖像源列表來設(shè)置它:    // Dependancy Property for the North Image     public static readonly DependencyProperty NorthImagePathProperty         = DependencyProperty.Register(             "NorthImagePath",             typeof(ImageSource),             typeof(MainWindow),             new PropertyMetadata("**Don't know what goes here!!!**"));     // Property wrapper for the dependancy property     public ImageSource NorthImagePath     {         get { return (ImageSource)GetValue(NorthImagePathProperty); }         set { SetValue(NorthImagePathProperty, value); }     }
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 473 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)