This is a migrated thread and some comments may be shown as answers.

ContextMenu and Resources

2 Answers 38 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Guga
Top achievements
Rank 1
Guga asked on 17 Dec 2012, 11:57 PM
Hi guys,

I have a customized schedule view with a context menu that shows different menu options depending on where the user clicks (appointments, empty slots, resources).

I have no problem getting the first two using the GetClickedElement<T> method. But ResourceItem doesn't derive from FrameworkElement so I can't use its type on the method.

I am using a CustomResourceTemplate:

<local:CustomGroupHeaderContentTemplateSelector.CustomResourceTemplate>
    <DataTemplate>
        <Border Height="40" Width="180" Margin="1 1 1 0" >
            <StackPanel Margin="1" Orientation="Vertical" HorizontalAlignment="Stretch">
                <TextBlock FontFamily="Calibri" FontSize="8" FontStyle="Italic" TextAlignment="Center" Margin="1" Text="{Binding Name.DisplayName}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  Tag="ResourceItem" />
            </StackPanel>
        </Border>
    </DataTemplate>
</local:CustomGroupHeaderContentTemplateSelector.CustomResourceTemplate>

I tried passing the TextBlock type and I could test the Tag field, but the method always returns null.

Any ideas?

Cheers

2 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 21 Dec 2012, 12:36 PM
Hello,

Could you explain to us the scenario you are trying to achieve by accessing the ResourceItem with the right mouse click so we can see what is the best approach you could use?

Regards,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Alex
Top achievements
Rank 1
answered on 22 May 2013, 07:11 AM
Hello,

I found a workaround for the right click on the resources of a scheduleview timeline... I am not doing it through the radContectMenu but I am using the OrientedGroupHeaderContentTemplateSelector and the items in the StackPanel to get to right mouseclick events. Now it will give something like a messagebox but in combination with the MouseEnter events you could also load the right resource and give it to the ContextMenu:

     <groupheader:OrientedGroupHeaderContentTemplateSelector x:Key="GroupHeaderContentTemplateSelector">
            <groupheader:OrientedGroupHeaderContentTemplateSelector.VerticalResourceTemplate>
                <DataTemplate>
                    <Border Width="200" Padding="0 0 0 0" Margin="15 0 10 0" Height="15">
                        <StackPanel Margin="0 0 0 0">
                            <StackPanel Orientation="Horizontal" Margin="0 0 10 0" Height="15" HorizontalAlignment="Left" VerticalAlignment="Center">
                                <Image Name="ResourcesImage" Width="10" Height="10" MouseRightButtonDown="ResourcesImage_MouseRightButtonDown_1" Tag="{Binding Name.DisplayName}"  Margin="0 0 10 0"  HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="Fill" Source="{Binding Name.sIcon}" />
                                <TextBlock Name="ResourcesText"  Height="15" Padding="0 0 0 0" MouseEnter="ResourcesText_MouseEnter_1" MouseRightButtonDown="ResourcesText_MouseRightButtonDown_1" Margin="0 0 10 0" FontSize="11" VerticalAlignment="Center" Text="{Binding Name.DisplayName}" Foreground="Black" />
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </DataTemplate>

            </groupheader:OrientedGroupHeaderContentTemplateSelector.VerticalResourceTemplate>
        </groupheader:OrientedGroupHeaderContentTemplateSelector>

Tags
ScheduleView
Asked by
Guga
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Alex
Top achievements
Rank 1
Share this question
or