2012-02-10 6 views
0

私は単純なWP7アプリケーションを使用していますが、Prism DelegateCommandを使用してApplicationBarButtonCommandにバインドしようとしています。ApplicationBarButtonCommandとDelegateCommandを使用したバインドエラー

コードは次のとおりです。

XAML:

<phone:PhoneApplicationPage.ApplicationBar> 
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"> 
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.share.rest.png" Text="Add"/> 
    </shell:ApplicationBar> 
</phone:PhoneApplicationPage.ApplicationBar> 

<wi:Interaction.Behaviors> 
    <i:ApplicationBarButtonCommand ButtonText="Add" CommandBinding="{Binding SaveMessageCommand, Mode=OneWay}" 
            CommandParameterBinding="{Binding CurrentUser.Id}"/> 
</wi:Interaction.Behaviors> 

のViewModel:

公共のICommand SaveMessageCommand {取得します。プライベートセット; }

public MainViewModel(IDataService dataService, INavigationService navigationService) 
{ 
    //Some initialization goes here 

    SaveMessageCommand = new DelegateCommand<int>(OnSaveMessage); 
} 

private void OnSaveMessage(int userId) 
{ 
    if (_navigationService != null) 
    { 
     // TODO : change 0 to real current user id 
     _navigationService.NavigateTo(new Uri(string.Format(ViewModelLocator.CreateNewMessageUrl, userId), 
        UriKind.Relative)); 
    } 
} 

Userクラス:私は、アプリケーションを実行すると

public class User : BaseModel 
{ 
    private int _id; 

    public int Id 
    { 
     get { return _id; } 
     set 
     { 
      if (value == _id) 
      { 
       return; 
      } 

      _id = value; 
      RaisePropertyChanged("Id"); 
     } 
    } 
} 

私が持っているデータエラー

System.Windows.Data Error: 'MS.Internal.Data.DynamicValueConverter' converter failed to convert value 'Microsoft.Practices.Prism.Commands.DelegateCommand`1[System.Int32]' (type 'Microsoft.Practices.Prism.Commands.DelegateCommand`1[System.Int32]'); BindingExpression: Path='SaveMessageCommand' DataItem='WindowsPhone_Application.ViewModel.MainViewModel' (HashCode=75877085); target element is 'Microsoft.Practices.Prism.Interactivity.ApplicationBarButtonCommand' (Name='null'); target property is 'CommandBinding' (type 'System.Windows.Data.Binding').. System.InvalidOperationException: Can't convert type Microsoft.Practices.Prism.Commands.DelegateCommand`1[System.Int32] to type System.Windows.Data.Binding. 

問題を引き起こす可能性がありますどのような任意のアイデア?

おかげ

答えて

0

は、問題を修正し、問題がSystem.Windows.Interactivityとあった、ちょうどプリズムに含まれている別のバージョンへの参照を置く

関連する問題