문제

I have a Windows Phone 8 app with a RadDataBoundListBox and an item template containing a context menu

<DataTemplate x:Key="ListboxItem">
    <Grid>
         <telerikPrimitives:RadContextMenu.ContextMenu>
                <telerikPrimitives:RadContextMenu IsFadeEnabled="False" x:Name="Menu"
                                      IsZoomEnabled="False">
                    <telerikPrimitives:RadContextMenuItem Content="{Binding LocalizedResources.Delete, Source={StaticResource LocalizedStrings}}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Tap">
                                <micro:ActionMessage MethodName="Delete">
                                    <micro:Parameter Value="{Binding Id}" />
                                </micro:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </telerikPrimitives:RadContextMenuItem>
                </telerikPrimitives:RadContextMenu>
            </telerikPrimitives:RadContextMenu.ContextMenu>
...
</DataTemplate>

and a public Delete(int) method in my ViewModel. When I click the Delete button in the context menu, I get no target found for method.

I guess the problem is the context menu (visual tree) and some more Caliburn "magic" is needed to make it work.

도움이 되었습니까?

해결책

The solution to this problem is to add a name to the root element of the view (e.g: x:Name="Page") and to add this to the RadContextMenu

<telerikPrimitives:RadContextMenu micro:Action.TargetWithoutContext="{Binding ElementName=Page, Path=DataContext}" ...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top