Мой ByteToStringConverter выполняет преобразование байтов в удобочитаемый размер (МБ, ГБ и т. д.)
Ошибка 1 Имя «ByteToStringConverter» не существует в пространстве имен «clr-namespace:zemanFileManager.Konverteri». C:\Users\Nikola\Documents\Visual Studio 2013\Projects\zemanFileManager\zemanFileManager\zemanFileManager.xaml 14 9 zemanFileManager
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace zemanFileManager.Konverteri
{
public class ByteToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
string size = "0 KB";
if (value != null)
{
double byteCount = 0;
byteCount = System.Convert.ToDouble(value);
if (byteCount >= 1073741824)
size = String.Format("{0:##.##}", byteCount / 1073741824) + " GB";
else if (byteCount >= 1048576)
size = String.Format("{0:##.##}", byteCount / 1048576) + " MB";
else if (byteCount >= 1024)
size = String.Format("{0:##.##}", byteCount / 1024) + " KB";
else if (byteCount > 0 && byteCount < 1024)
size = "1 KB"; //Bytes are unimportant ;)
}
return size;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
xaml, здесь я также понимаю, что ByteToStringConverter не существует в пространстве имен, хотя он существует. Я использую другой конвертер под названием HeaderToImageConverter, и он отлично работает...
Controls:MetroWindow x:Class="zemanFileManager.ZemanFileManager"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
GlowBrush="{DynamicResource AccentColorBrush}"
WindowStartupLocation="CenterScreen"
WindowState="Maximized"
Title="ZemanFileManager" Height="700" Width="870" MinHeight="500" MinWidth="870" Icon="Slike/floppySlika.png"
xmlns:local="clr-namespace:zemanFileManager"
>
<Window.Resources>
<local:ByteToStringConverter x:Key="BytesToString" />
</Window.Resources>
<ListView.View>
<GridView>
<GridViewColumn Width="220" Header="Ime" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Width="150" Header="Vrijeme kreiranja" DisplayMemberBinding="{Binding CreationTime}" />
<GridViewColumn Width="100" Header="Veličina" DisplayMemberBinding="{Binding XPath=Length, Converter={StaticResource BytesToString}}" />
<GridViewColumn Width="100" Header="Ekstenzija" DisplayMemberBinding="{Binding Extension}" />
</GridView>
</ListView.View>
</ListView>