Frage

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.

War es hilfreich?

Lösung

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}" ...
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top