This is a migrated thread and some comments may be shown as answers.
how use CommandParameter
1 Answer 48 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Park
Top achievements
Rank 1
Park asked on 31 Jan 2012, 02:31 PM
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;
            }


1 Answer, 1 is accepted

Sort by
0
Accepted
Victor
Telerik team
answered on 03 Feb 2012, 12:31 PM
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 >>

Tags
ContextMenu
Asked by
Park
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or