更新时间:2023-10-03 09:42:04
In contrast to XAML, it is necessary to specify the full Resource File Pack URI in code behind:
mDiag.Icon = new System.Windows.Controls.Image
{
Source = new BitmapImage(new Uri(
"pack://application:,,,/assets/checked-32-context.png"))
};
还请注意,这不是相对URI.
Note also that this is not a relative URI.