c# - Cannot resolve DataType MyApp.Model.Paper -
i'm trying bind class template.
<usercontrol x:class="myapp.controls.paperselectcontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:myapp.controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" d:designheight="300" d:designwidth="400"> <grid> <scrollviewer> <gridview x:name="papergrid" itemssource="{x:bind papers}" width="400" height="300" > <gridview.itemtemplate > <datatemplate x:datatype="myapp.model.paper" > <textblock text="{x:bind color}"/> </datatemplate> </gridview.itemtemplate> </gridview> </scrollviewer> </grid> </usercontrol>
the myapp.model.paper
class namespace.
namespace myapp.model { public class paper { public string name { get; set; } public string color { get; set; } public string thumb { get; set; } } }
but
cannot resolve datatype myapp.model.paper
error
i hope can me resolve issue. thank you.
as far known cannot set x:datatype
markup namespace.class
format. accessing own custom types can map xaml namespace, mapping made defining xmlns
prefix. example, xmlns:mytypes
defines new xaml namespace accessed prefixing usages token mytypes:
.
so please add mapping xmlns:model="using:myapp.model"
header markup list. , updated xaml code x:datatype
follows: <datatemplate x:datatype="model:paper" >
, build project work.
more details please reference mapping custom types xaml namespaces , prefixes.
Comments
Post a Comment