C# and WPF tutorial files

This commit is contained in:
Unknown
2017-05-29 21:01:07 +01:00
parent dfdd754362
commit 1cb838df3a
107 changed files with 5760 additions and 0 deletions

View File

@ -0,0 +1,40 @@
using System;
using System.Globalization;
using System.IO;
using System.Windows.Data;
using System.Windows.Media.Imaging;
namespace WpfTreeView
{
/// <summary>
/// Converts a full path to a specific image type of a drive, folder or file
/// </summary>
[ValueConversion(typeof(DirectoryItemType), typeof(BitmapImage))]
public class HeaderToImageConverter : IValueConverter
{
public static HeaderToImageConverter Instance = new HeaderToImageConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// By default, we presume an image
var image = "Images/file.png";
switch ((DirectoryItemType)value)
{
case DirectoryItemType.Drive:
image = "Images/drive.png";
break;
case DirectoryItemType.Folder:
image = "Images/folder-closed.png";
break;
}
return new BitmapImage(new Uri($"pack://application:,,,/{image}"));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}