Mvvm Windows Phone 8 command Error: BindingExpression path error: 'SalvarCommand' -
my commands pointing model class , not modelview
system.windows.data error: bindingexpression path error: 'salvarcommand' property not found on 'superlistaw8.model.listaitem' 'superlistaw8.model.listaitem'
editlistapage.xaml
<phone:phoneapplicationpage x:class="superlistaw8.view.editlistapage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone" xmlns:shell="clr-namespace:microsoft.phone.shell;assembly=microsoft.phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:wm="clr-namespace:system.windows.controls;assembly=windowsphonewatermarktextboxcontrol" xmlns:i="clr-namespace:system.windows.interactivity;assembly=system.windows.interactivity" xmlns:cmd="clr-namespace:galasoft.mvvmlight.command;assembly=galasoft.mvvmlight.extras.wp8" fontfamily="{staticresource phonefontfamilynormal}" fontsize="{staticresource phonefontsizenormal}" foreground="{staticresource phoneforegroundbrush}" supportedorientations="portrait" orientation="portrait" datacontext="{binding source={staticresource locator}, path=listaviewmodel}" mc:ignorable="d" shell:systemtray.isvisible="true"> editlistapage.xaml --> block text
<textbox grid.column="1" background="#f3f3f3" borderbrush="#f3f3f3" verticalalignment="top"> <i:interaction.triggers> <i:eventtrigger eventname="textchanged"> <cmd:eventtocommand command="{binding path=salvarcommand, mode=twoway}" passeventargstocommand="true"/> </i:eventtrigger> </i:interaction.triggers> </textbox> viewmodellocator.cs
namespace superlistaw8.viewmodel { public class viewmodellocator { public viewmodellocator() { servicelocator.setlocatorprovider(() => simpleioc.default); if (!simpleioc.default.isregistered<idataservice>()) { simpleioc.default.register<idataservice, dataservice>(); //simpleioc.default.register<inavigationservice>(() => new navigationservice()); } simpleioc.default.register<listaviewmodel>(); } public listaviewmodel listaviewmodel { { return servicelocator.current.getinstance<listaviewmodel>(); } } public static void cleanup() { } } } listaviewmodel.cs
namespace superlistaw8.viewmodel { public class listaviewmodel : viewmodelbase { public relaycommand salvarcommand { get; private set; } public listaviewmodel(idataservice dataservice) { _dataservice = dataservice; salvarcommand = new relaycommand(() => { system.diagnostics.debugger.break(); }); } } } my commands being sought in model , not in viewmodel listaitem listaviewmodel. can me?
you name listbox , in binding reference elementname, , in path use datacontext.detailsvisibility
<listbox x:name="listbox" itemssource="{binding items}"> <listbox.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <textblock text="{binding title}" /> <textblock text="{binding details}" visibility="{binding elementname=listbox, path=datacontext.detailsvisibilty}" /> </stackpanel> </datatemplate> </listbox.itemtemplate>
Comments
Post a Comment