Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
XamMenu ItemClicked on MVVM not giving command parameter Value on the function call
posted

<UserControl.Resources>

<DataTemplate x:Key="MenuDataTemplate">
           <StackPanel Orientation="Horizontal">
                <Border Padding="0">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=MenuName}"/>
                    </StackPanel>
                </Border>
            </StackPanel>
              
        </DataTemplate>
    </UserControl.Resources>

 

  <ig:XamMenu x:Name="MainMenu"
               VerticalAlignment="Top"
               MenuOrientation="Horizontal"
               ItemTemplate="{StaticResource MenuDataTemplate}"
               ItemsSource="{Binding Path=userMenuItems}"
               HorizontalAlignment="Stretch"
            >
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="ItemClicked">
                    <i:InvokeCommandAction  Command="{Binding Path=SwitchPageCommand}" CommandParameter="{Binding Path=MenuName}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>


            <ig:XamMenu.HierarchicalItemTemplate>
                <ig:HierarchicalDataTemplate ItemTemplate="{StaticResource MenuDataTemplate}"
                                             ItemsSource="{Binding Path=Children}"
                                             >
                    <ig:HierarchicalDataTemplate.DefaultItemsContainer>
                        <DataTemplate>
                            <ig:XamMenuItem>
                                <ig:XamMenuItem.Icon>
                                    <Image Source="{Binding MenuImageURL}" />
                                </ig:XamMenuItem.Icon>
                            </ig:XamMenuItem>
                        </DataTemplate>
                    </ig:HierarchicalDataTemplate.DefaultItemsContainer>
                </ig:HierarchicalDataTemplate>
            </ig:XamMenu.HierarchicalItemTemplate>
        </ig:XamMenu>

 

ViewModel Code :

 public ICommand SwitchPageCommand { get; private set; }

SwitchPageCommand = new DelegateCommand(executeAction: param => MenuItemClick(param), canExecute: delegate { return true; });

public void MenuItemClick(object menuID)
        {

// function is called but not giving any parameter values

        }

Model Class:

 [DataContract]
    public class MenuDataItem
    {

        [DataMember]
        public string MenuName
        {
            get;
            set;
        }

     
        [DataMember]
        public int? MenuId
        {
            get;
            set;
        }

        //[DataMember]
        //public int? ParentId
        //{
        //    get;
        //    set;
        //}

        [DataMember]
        public string MenuImageURL
        {
            get;
            set;
        }

        [DataMember]
        public List<MenuDataItem> Children
        {
            get;
            set;
        }
    }

May I know what should we make a change to correct it.

Parents Reply Children
No Data