0
我的命令指向Model類而不是模型視圖MVVM的Windows Phone 8命令錯誤:BindingExpression路徑錯誤:「SalvarCommand」
System.Windows.Data錯誤:BindingExpression路徑錯誤:「SalvarCommand」屬性未找到上 '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 - >塊文本
個<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
{
get
{
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();
});
}
}
}
我的命令,正在尋求在模型中,而不是在視圖模型ListaItem ListaViewModel。誰能幫我?