c# - ByteToStringConverter does not implement interface member ...IValueConverter.ConvertBack(...)'? -
my bytetostringconverter, job converting bytes human readable size (mb, gb, etc)
error 1 name "bytetostringconverter" not exist in namespace "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 unimportant ;) } return size; } public object convertback(object value, type targettype, object parameter, string language) { throw new notimplementedexception(); } }
xaml code, in here bytetostringconverter not exist in namespace although exist. using converter called headertoimageconverter , 1 works fine...
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>
your xml namespace declaration local
references namespace zemanfilemanager
, converter in namespace zemanfilemanager.konverteri
.
add namespace declaration:
xmlns:converter="clr-namespace:zemanfilemanager.konverteri" ... <converter:bytetostringconverter x:key="bytestostring" />
Comments
Post a Comment