This project is read-only.

CommandParameter binding

Dec 21, 2012 at 1:28 PM
Edited Dec 28, 2012 at 1:15 PM

Hi,

is possible use binding in CommandParameter from another element?

Thanks

<toolkit:LongListMultiSelector
     x:Name="folders"
     IsSelectionEnabledChanged="FoldersSelectionEnableChanged"
     ItemsSource="{Binding Path=ParentFolder.Items}"
     ItemTemplate="{StaticResource FolderTemplate}" />
<appBar:AppBarButton
     Command="{Binding Path=DeleteCommand}"
     CommandParameter="{Binding Path=SelectedItems, ElementName=folders}"
     IconUri="/Icons/appBar.delete.png"
     Text="{Binding Path=LocalizedResources.Delete, Source={StaticResource LocalizedStrings}}" />
public RelayCommand<IList> DeleteCommand { get; private set; }
private void Delete(IList selectedFolders)
{
// selectedFolders => always null
}
May 23, 2013 at 6:46 AM
Edited May 26, 2013 at 3:31 AM
Hi there,

Well, I've checked that there's already a CommandParameter dependency property in AppBarButton. You should be able to do such binding.

Can you try placing the AppBarButton code behind the LongListMultiSelector code in XAML order?

Thanks/Allen
Mar 9, 2014 at 3:46 AM
Edited Mar 9, 2014 at 9:17 PM
This is an old thread, but I've just come across this problem as well. CommandParamter is always null. My AppBar XAML code is first and I'm using Coding4Fun's ColorPicker afterwards (binding to Color).

I'm just going to work around it by binding the element property to a property in my viewmodel and just using that during the command event.

I should also mention that this is a great project. I can't believe I did without AppBar button binding for so long. Thank you!
May 25, 2014 at 2:12 PM
Hi, I have tried binding a ListBox Selected Item to the CommandParameter and have also found that it always null. Is this still an outstanding issue?

Thanks to @leemcpherson for his suggested work around in the meantime.