how use CommandParameter

2 posts, 1 answers
  1. Park
    Park avatar
    39 posts
    Member since:
    Sep 2010

    Posted 31 Jan 2012 Link to this post

    hi

    my project is using MVVM Light Toolkit.
    so, all property, all command binding
    but, i can't bind CommandParameter with control in view

         <telerikPrimitives:RadDataBoundListBox x:Name="lbStationDetail" Grid.Row="1" EmptyContent="검색된 결과가 없습니다."
                                                                 ItemsSource="{Binding BusVM.StationNoCollection}" ItemTemplate="{StaticResource StationNoRouteDataTemplate}" >
          <telerikPrimitives:RadContextMenu.ContextMenu>
           <telerikPrimitives:RadContextMenu>
            <telerikPrimitives:RadContextMenuItem Content="즐겨찾기 추가" Command="{Binding AddFavoriteCommand, Mode=OneWay}" CommandParameter="{Binding }"/>
           </telerikPrimitives:RadContextMenu>
          </telerikPrimitives:RadContextMenu.ContextMenu>
         </telerikPrimitives:RadDataBoundListBox>

    how can i know hold item?

    add

    i find somting. but, i can't get RadDataBoundListBoxItem
    menu is get currentFocusedElement property.
    how can i do get it?

            RelayCommand<object> addFavoriteCommand;
            /// <summary>
            /// 즐겨찾기에 추가
            /// </summary>
            public RelayCommand<object> AddFavoriteCommand
            {
                get
                {
                    if (addFavoriteCommand == null)
                    {
                        addFavoriteCommand = new RelayCommand<object>(item =>
                        {
                            var menuItem = item as RadContextMenuItem;
                            var menu = menuItem.Parent as RadContextMenu;
                            var tt = menu.GetElementUnderMenu<RadDataBoundListBoxItem>();
                            //var tt = menu.GetType().GetElementType();
                            //var lb = menu.Parent as RadDataBoundListBox;
                            if (tt != null)
                            {
                            }

                        });
                    }
                    return addFavoriteCommand;
                }


  2. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 03 Feb 2012 Link to this post

    Hi Park,

     Thank you for writing.
    Please have a look at this help article. In short, you can always get a reference to the focused element in RadContextMenu's Opening event. Please write again if you need further assistance.

    Regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top