views:

54

answers:

0

Desired Result:

Create a quick XAML example of Silverlight 4 ComboBox, where each ComboBoxItem is made up of multiple TextBlocks. Every Textblock in the ComboBoxItem has it's own unique (Silverlight Toolkit) ContextMenu item. Rightclicking the Textblock brings up the relate context menu.

Working properly:

I have successfully created the ComboBox and ComboBoxItems. When the ComboBox is open I can right click on a TextBlock inside one of the items and it displays the expected ContextMenu.

Not Working:

Right clicking a TextBlock of the selected ComboBoxItem only shows the standard Silverlight context menu and not the unique Toolkit ContextMenu I was expecting for that Textblock.

XAML Code:

<ComboBox Height="103" HorizontalAlignment="Left" Margin="0,-1,0,0" Name="comboBox1" VerticalAlignment="Top" Width="355" FlowDirection="LeftToRight">
        <ComboBoxItem>
            <StackPanel Orientation="Vertical">
                <TextBlock Text="Joe Smith" FontSize="20">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                            <toolkit:MenuItem Header="Name: Joe"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </TextBlock>
                <TextBlock Text="Microsoft Inc.">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                            <toolkit:MenuItem Header="Company: Joe"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </TextBlock>
                <TextBlock Text="1 Microsoft Way">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                            <toolkit:MenuItem Header="Address: Joe"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </TextBlock>
                <TextBlock Text="Redmond, WA 98052">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                            <toolkit:MenuItem Header="CSZ: Joe"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </TextBlock>
            </StackPanel>
        </ComboBoxItem>
        <ComboBoxItem>
            <StackPanel Orientation="Vertical">
                <TextBlock Text="Lisa Lee" FontSize="20">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                            <toolkit:MenuItem Header="Name: Lisa"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </TextBlock>
                <TextBlock Text="Google Inc.">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                            <toolkit:MenuItem Header="Company: Lisa"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </TextBlock>
                <TextBlock Text="1600 Amphitheatre Parkway">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                            <toolkit:MenuItem Header="Address: Lisa"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </TextBlock>
                <TextBlock Text="Mountain View, CA 94043">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                            <toolkit:MenuItem Header="CSZ: Lisa"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </TextBlock>
            </StackPanel>
        </ComboBoxItem>
    </ComboBox>

TLDR:

My Silverlight Toolkit Context Menus on individual Textblocks inside of my ComboBoxItem don't display when the ComboBoxItem is selected but do when the ComboBox is open.