我正在尝试创建一个带有TreeView元素的资源管理器应用程序,并且每个树级别都有不同的图标。我遵循了这篇文章:http://www.codeproject.com/Articles/21248/A-Simple-WPF-Explorer-Tree,一切都运行良好,但是我还想拥有不同大小的图标。
我的Image元素XAML如下:
<Image Name="img"
Source="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type TreeViewItem}},
Path=Header,
Converter={x:Static local:HeaderToImageConverter.Instance}}"
/>
决定返回哪个图标的代码如下:
if ((value as string).Contains(@"\""))
{
Uri uri = new Uri ("pack://application:,,,/Images/DeployWiz_Network.png");
BitmapImage source = new BitmapImage(uri);
return source;
}
我该如何更改返回的图像尺寸?更改位图图像对象的尺寸似乎不起作用。还有哪些图像对象可以作为源返回?