Windows phone Windows phone 8应用程序栏命令参数始终为空-Cimbalino
Xaml名称空间Windows phone Windows phone 8应用程序栏命令参数始终为空-Cimbalino,windows-phone,winrt-xaml,mvvm-light,windows-phone-toolkit,cimbalino,Windows Phone,Winrt Xaml,Mvvm Light,Windows Phone Toolkit,Cimbalino,Xaml名称空间 xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:appBar="clr-namespace:Cimbalino.Phone.Toolkit.Behaviors;assembly=Cimbalino.Phone.Toolkit"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WP8"
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel"
Grid.Row="0"
Margin="12,17,0,28">
<TextBlock Text="Beneficiary"
Margin="9,-7,0,0"
Style="{StaticResource PhoneTextTitle1Style}" />
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<toolkit:LongListMultiSelector
x:Name="beneficoryList"
ItemsSource="{Binding BeneficoryCollection}"
EnforceIsSelectionEnabled="{Binding DataContext.IsSelectionEnabled, ElementName=LayoutRoot,Mode=TwoWay}">
<!--Is Selection Enabled Changed Command-->
<!--<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="IsSelectionEnabledChanged">
<interactivity:InvokeCommandAction Command="{Binding DataContext.IsSelectionEnabledChangedOn,ElementName=LayoutRoot,Mode=OneTime}"/>
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>-->
<toolkit:LongListMultiSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" FontSize="{StaticResource PhoneFontSizeLarge}"/>
<TextBlock Text="{Binding Number}" FontSize="{StaticResource PhoneFontSizeMedium}"/>
<TextBlock Text="{Binding Operator}" FontSize="{StaticResource PhoneFontSizeSmall}"/>
<!-- Interaction region-->
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="Tap">
<interactivity:InvokeCommandAction Command="{Binding TapCommand}" CommandParameter="{Binding }"/>
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
<!-- Interaction region ends-->
</StackPanel>
</DataTemplate>
</toolkit:LongListMultiSelector.ItemTemplate>
</toolkit:LongListMultiSelector>
</Grid>
</Grid>
<interactivity:Interaction.Behaviors>
<appBar:ApplicationBarBehavior x:Name="appBar" IsVisible="True"
BackgroundColor="{StaticResource PhoneAccentColor}"
ForegroundColor="{StaticResource PhoneBackgroundColor}" Mode="Default">
<appBar:ApplicationBarIconButton Text="Add"
IconUri="/Toolkit.Content/ApplicationBar.Add.png"
IsVisible="{Binding IsAddCommandVisible,Mode=TwoWay}"
Command="{Binding AddCommand}"/>
<appBar:ApplicationBarIconButton Text="Delete"
IconUri="/Toolkit.Content/ApplicationBar.Delete.png"
Command="{Binding DeleteCommand,Mode=OneTime}"
CommandParameter="{Binding SelectedItems,ElementName=beneficoryList}"/>
<!--Menu Items-->
<appBar:ApplicationBarBehavior.MenuItems>
<appBar:ApplicationBarMenuItem Text="HelpDesk" />
<appBar:ApplicationBarMenuItem Text="Contact Us"/>
</appBar:ApplicationBarBehavior.MenuItems>
<!--Menu Items End-->
</appBar:ApplicationBarBehavior>
</interactivity:Interaction.Behaviors>
xmlns:toolkit=“clr命名空间:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.toolkit”
xmlns:interactivity=“clr命名空间:System.Windows.interactivity;assembly=System.Windows.interactivity”
xmlns:appBar=“clr命名空间:Cimbalino.Phone.Toolkit.Behaviors;assembly=Cimbalino.Phone.Toolkit”
xmlns:cmd=“clr命名空间:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WP8”
xmlns:toolkit=“clr命名空间:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.toolkit”
xmlns:interactivity=“clr命名空间:System.Windows.interactivity;assembly=System.Windows.interactivity”
xmlns:appBar=“clr命名空间:Cimbalino.Phone.Toolkit.Behaviors;assembly=Cimbalino.Phone.Toolkit”
xmlns:cmd=“clr命名空间:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WP8”
在可视化树中找不到元素“BenegoryList”,我将应用程序栏放置在网格外部,现在我将应用程序栏移动到网格内部,因此现在选择了“BenegoryList”,并将其传递给VM。我想WP只允许遍历到它的直接父对象我自己已经尝试了几天了。我认为这应该是可能的,但我所发现的一切都表明这是不可能的。您最好将所需绑定到其他位置的视图模型,并在调用此命令时在其中访问它。@Poken1151我发现,我做错了什么,我将应用程序栏移到了网格中,在那里我可以找到我的列表框。。我很感激你的努力,谢谢。我得试试西姆巴利诺。我无法使用可绑定的应用程序栏执行此操作。谢谢你的更新。@Poken1151,Cimbalino真是太棒了,你知道在没有后台代理的情况下创建一个本地土司吗。我想在应用程序处于前台时展示一个祝酒词,您仍然可以在根元素上使用它,只要您了解它是不同的Xaml名称范围并使用NamescopeBinding
helper;有关这方面的更多信息,请点击此处:
private RelayCommand<object> _ondeleteCommand;
public RelayCommand<object> DeleteCommand
{
get { return _ondeleteCommand ?? (_ondeleteCommand = new RelayCommand<object>(OnDeleteCommand)); }
}
private void OnDeleteCommand(object tobeDeleted)
{
if (tobeDeleted != null)
{
// Delete
}
}
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:appBar="clr-namespace:Cimbalino.Phone.Toolkit.Behaviors;assembly=Cimbalino.Phone.Toolkit"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WP8"
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!--App Bar Binding-->
<interactivity:Interaction.Behaviors>
<appBar:ApplicationBarBehavior x:Name="appBar" IsVisible="True"
BackgroundColor="{StaticResource PhoneAccentColor}"
ForegroundColor="{StaticResource PhoneBackgroundColor}" Mode="Default">
<appBar:ApplicationBarIconButton Text="Add"
IconUri="/Toolkit.Content/ApplicationBar.Add.png"
IsVisible="{Binding IsAddCommandVisible,Mode=TwoWay}"
Command="{Binding AddCommand}"/>
<appBar:ApplicationBarIconButton Text="Delete"
IconUri="/Toolkit.Content/ApplicationBar.Delete.png"
Command="{Binding DeleteCommand,Mode=OneTime}"
CommandParameter="{Binding SelectedItems,ElementName=beneficoryList}"/>
<!--Menu Items-->
<appBar:ApplicationBarBehavior.MenuItems>
<appBar:ApplicationBarMenuItem Text="HelpDesk" />
<appBar:ApplicationBarMenuItem Text="Contact Us"/>
</appBar:ApplicationBarBehavior.MenuItems>
<!--Menu Items End-->
</appBar:ApplicationBarBehavior>
</interactivity:Interaction.Behaviors>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel"
Grid.Row="0"
Margin="12,17,0,28">
<TextBlock Text="Beneficiary"
Margin="9,-7,0,0"
Style="{StaticResource PhoneTextTitle1Style}" />
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<toolkit:LongListMultiSelector
x:Name="beneficoryList"
ItemsSource="{Binding BeneficoryCollection}"
EnforceIsSelectionEnabled="{Binding DataContext.IsSelectionEnabled, ElementName=LayoutRoot,Mode=TwoWay}">
<toolkit:LongListMultiSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" FontSize="{StaticResource PhoneFontSizeLarge}"/>
<TextBlock Text="{Binding Number}" FontSize="{StaticResource PhoneFontSizeMedium}"/>
<TextBlock Text="{Binding Operator}" FontSize="{StaticResource PhoneFontSizeSmall}"/>
<!-- Interaction region-->
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="Tap">
<interactivity:InvokeCommandAction Command="{Binding TapCommand}" CommandParameter="{Binding }"/>
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
<!-- Interaction region ends-->
</StackPanel>
</DataTemplate>
</toolkit:LongListMultiSelector.ItemTemplate>
</toolkit:LongListMultiSelector>
</Grid>
</Grid>