Hey together,
I have a MapControl in my application in which I have different MapLayers with different MapItemsControls.
To a few of them I want to add ContextMenues if someone rightclicks. For example to create a route from Pushpin A to B, to add it to some existing things etc.
To make the second option easy, I want to add a RadCombobox to the ContextMenue and populate it with the data of an ObservableCollection that is part of the DataContext of the RadWindow.
The problem is, that the RadComboBox stays empty. If I add the RadComboBox directly without the ContextMenu it gets populated as it should.
Also if I put the ContextMenu directly into the MapLayer it populates, but I need the Source of the Pushpin as a Commandparameter later so I can trigger some things with the underlying element.
<map:MapLayer x:Name="MapLayerAufträge" > <map:MapItemsControl ItemsSource="{Binding AufträgeLocations}" > <map:MapItemsControl.ItemTemplate> <DataTemplate> <map:Pushpin Location="{Binding Location}" Visibility="{Binding Path=IsVisible, Converter={StaticResource VisibleIfTrueConverter}}" ToolTip="{Binding Name}" MouseLeftButtonDown="MontageAufträgePushpin_MouseDown" > <map:Pushpin.Background> <SolidColorBrush Color="{Binding MontageEinteilung, Converter={StaticResource AuftragMontageEingeteiltPinFarbeConverter}}" Opacity="0.8" /> </map:Pushpin.Background> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="rcmKarte" > <telerik:RadMenuItem Header="Tour starten"/> <telerik:RadMenuItem Header="Zu Tour hinzufügen" > <telerik:RadComboBox ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadWindow}}, Path=DataContext.Touren, Mode=OneWay}" SelectedValuePath="ID" > <telerik:RadComboBox.ItemTemplate> <DataTemplate> <Grid Margin="0 3" > <StackPanel Orientation="Horizontal" > <TextBlock Text="{Binding Monteure}"/> <TextBlock Text=" KW: " /> <TextBlock Text="{Binding KWsString}"/> <TextBlock Text=" (" /> <TextBlock Text="{Binding DatumStart, StringFormat=d}" /> <TextBlock Text="-" /> <TextBlock Text="{Binding DatumEnde, StringFormat=d}" /> <TextBlock Text=")" /> </StackPanel> </Grid> </DataTemplate> </telerik:RadComboBox.ItemTemplate> </telerik:RadComboBox> <Button Content="Bestätigen" Command="{Binding PutInTourCommand}" /> </telerik:RadMenuItem> </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu> </map:Pushpin> </DataTemplate> </map:MapItemsControl.ItemTemplate> </map:MapItemsControl> <map:MapItemsControl ItemsSource="{Binding SelectedAufträgeLocations}" > <map:MapItemsControl.ItemTemplate> <DataTemplate> <map:Pushpin Location="{Binding LagerLocation.Location}" ToolTip="{Binding Name}" Template="{StaticResource LagerPushpinTemplate}" PositionOrigin="0.45, 0.45" > <map:Pushpin.Background> <SolidColorBrush Color="#EF6C00" /> </map:Pushpin.Background> </map:Pushpin> </DataTemplate> </map:MapItemsControl.ItemTemplate> </map:MapItemsControl> <map:MapItemsControl ItemsSource="{Binding SelectedAufträgeLocations}" > <map:MapItemsControl.ItemTemplate> <DataTemplate> <map:Pushpin Location="{Binding Location}" ToolTip="{Binding Name}" > <map:Pushpin.Background> <SolidColorBrush Color="#EF6C00" Opacity="0.8" /> </map:Pushpin.Background> </map:Pushpin> </DataTemplate> </map:MapItemsControl.ItemTemplate> </map:MapItemsControl></map:MapLayer>
Has anyone an idea how I can achieve this?
Greetings,
Benedikt
