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

Radsplitbutton gives errors

9 Answers 111 Views
Navigation
This is a migrated thread and some comments may be shown as answers.
Ronald Evers
Top achievements
Rank 1
Ronald Evers asked on 06 Apr 2010, 10:46 AM
Hey,

I recently implemented the Radsplitbutton but it gives an error whenever I open it a second time. Here's the code I used:
 <telerik:RadSplitButton  
                x:Name="newButton" 
                IsToggle="True" 
                Width="120" 
                Click="newButton_Click" 
                controls:DockPanel.Dock="Left" 
                HorizontalAlignment="Left" 
                Height="30" 
                > 
                <telerik:RadSplitButton.Content> 
                    <StackPanel 
                        Orientation="Horizontal"
                        <Image 
                            HorizontalAlignment="Left" 
                            Source="/Resources;component/Images/Default/contactperson_24.png" Width="20" /> 
                        <TextBlock 
                            Text="{Binding button_new_relation, Source={StaticResource resxString}, Mode=OneWay}" 
                            HorizontalAlignment="Left" 
                /> 
                    </StackPanel> 
                </telerik:RadSplitButton.Content> 
                    <telerik:RadSplitButton.DropDownContent> 
                        <telerikNavigation:RadContextMenu BorderThickness="0" ItemClick="RadContextMenu_ItemClick"
                            <telerikNavigation:RadMenuItem 
                                    Header="{Binding button_new_contact_person, Source={StaticResource resxString}, Mode=OneWay}" Tag="CONTACTPERSON" > 
                                <telerikNavigation:RadMenuItem.Icon> 
                                    <Image Stretch="None" Source="/Resources;component/Images/Default/contactperson_24.png"/> 
                                </telerikNavigation:RadMenuItem.Icon> 
                            </telerikNavigation:RadMenuItem> 
                            <telerikNavigation:RadMenuItem 
                                    Header="{Binding button_new_contact_company, Source={StaticResource resxString}, Mode=OneWay}" Tag="CONTACTCOMPANY" > 
                                <telerikNavigation:RadMenuItem.Icon> 
                                    <Image Stretch="None" Source="/Resources;component/Images/Default  /contactcompany_24.png"/> 
                                </telerikNavigation:RadMenuItem.Icon> 
                            </telerikNavigation:RadMenuItem> 
                        </telerikNavigation:RadContextMenu> 
                    </telerik:RadSplitButton.DropDownContent> 
                </telerik:RadSplitButton> 


Relatively straightforward. 2 items in the context menu that consist of a picture and text and it's all defined in the xaml, nothing bound except the resource strings.Does anyone know why this is happening? The error is as following:

Error HRESULT E_FAIL has been returned from a call to a COM component.

Thanks for your time.

9 Answers, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 08 Apr 2010, 03:30 PM
Hi Ronald,

Thank you for contacting us.

Let me explain a bit deeper about the RadContextMenu.

This control is especially designed to be opened via an attached property. Because of this it should not be used as a content of a control.

However this control looks pretty silky and sometimes we are working around the above statement. But this is a bit tricky approach - even we can get a nice looking menu, it will be a half-functioning one - for example we should sacrifice sub-menus. Please note our example follows strictly this workaround.

Finally. If you still would like to use a button with RadContextMenu please follow the instructions in the A DropDown Button with RadContextMenu article. For your convenience we will place a ready for use code here:
 
Copy Code
<telerik:RadToggleButton
    Content="Click me â–¼"
    IsChecked="{Binding IsOpen, ElementName=context, Mode=TwoWay}">
    <telerikNavigation:RadContextMenu.ContextMenu>
        <telerikNavigation:RadContextMenu
            x:Name="context" Placement="Bottom">
            <telerikNavigation:RadMenuItem Header="Item 1">
                <telerikNavigation:RadMenuItem Header="Item A" />
                <telerikNavigation:RadMenuItem Header="Item B" />
            </telerikNavigation:RadMenuItem>
            <telerikNavigation:RadMenuItem Header="Item 2" />
            <telerikNavigation:RadMenuItem Header="Item 3" />
        </telerikNavigation:RadContextMenu>
    </telerikNavigation:RadContextMenu.ContextMenu>
</telerik:RadToggleButton>
 
We hope this information will help you.

Sincerely yours,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ronald Evers
Top achievements
Rank 1
answered on 09 Apr 2010, 11:12 AM
Hi,

Thanks for your reply. I understand what you're getting at, however I would not like to use the dropdown button, I'd prefer to use the splitbutton. I used the code as displayed here: http://demos.telerik.com/silverlight/#Buttons/SplitButton.
As you can see there in the example it's the same approach as I used, a split button with a context menu as it's content. I tried adding the context menu as an attached property like you said but I get the error that the content can only be set once, which makes sense I guess.
I'll have another look at the example as explained in the demo, maybe I did something wrong, but the one you gave me is not for the control I want.

Hopefully there is another way of doing this with the splitbutton?
0
Ivan
Telerik team
answered on 12 Apr 2010, 02:53 PM
Hi Ronald,

Indeed we can use the RadMenu as a drop-down content. Just replace the RadContextMenu with the code below (please note the Orientation is initialized to Vertical):
 
<telerikNavigation:RadMenu Orientation="Vertical">
    <telerikNavigation:RadMenuItem ...
 
However now the drop down content will look not so silky and you should apply a custom style (to the RadMenu) in order to change this. Other approach is to use a set of RadButtons - for example a stack panel with some buttons inside.

Please try the variants above and let us know if we can help you.


All the best,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ronald Evers
Top achievements
Rank 1
answered on 13 Apr 2010, 09:59 AM
Hi Ivan,

I see what you mean now. However I regret to inform you that after changing the context menu to a normal radmenu the error still occurs.
The error is as following:
"Error HRESULT E_FAIL has been returned from a call to a COM component."

It happens whenever I open the dropdown menu for the RadSplitButton a second time.

Here is the code I'm using now, as per your example:

<telerik:RadSplitButton.Content> 
                <StackPanel 
                Orientation="Vertical"
                    <Image 
                    Source="/VenumBvVenumInfraResources;component/Images/Default/assignment_24.png" Width="20" /> 
                    <TextBlock 
                    Text="{Binding Resource.button_new}" 
                    /> 
                </StackPanel> 
            </telerik:RadSplitButton.Content> 
            <telerik:RadSplitButton.DropDownContent> 
                <telerikNavigation:RadMenu Orientation="Vertical"
                    <telerikNavigation:RadMenuItem 
                                    Header="{Binding Resource.button_new_assignment}" Tag="ASSIGNMENT" > 
                        <telerikNavigation:RadMenuItem.Icon> 
                            <Image Stretch="None" Source="/VenumBvVenumInfraResources;component/Images/Default/assignment_24.png"/> 
                        </telerikNavigation:RadMenuItem.Icon> 
                    </telerikNavigation:RadMenuItem> 
                    <telerikNavigation:RadMenuItem IsSeparator="True" /> 
                    <telerikNavigation:RadMenuItem 
                                    Header="{Binding Resource.button_new_agendaitem}" Tag="AGENDA"  > 
                        <telerikNavigation:RadMenuItem.Icon> 
                            <Image Stretch="None" Source="/VenumBvVenumInfraResources;component/Images/Default/scheduler_24.png"/> 
                        </telerikNavigation:RadMenuItem.Icon> 
                    </telerikNavigation:RadMenuItem> 
                   </telerik:RadSplitButton.DropDownContent> 
        </telerik:RadSplitButton> 

I assume there is something going wrong with the RadSplitButton itself, or perhaps the menu items which are identical in both the RadMenu and the RadContextMenu. It happens when I click the arrow in the RadSplitButton though.

I hope you can recreate the bug.




0
Accepted
Ivan
Telerik team
answered on 16 Apr 2010, 07:52 AM
Hi Ronald,

Thank you for the sample code.

Here we tested your code and found everything is OK. We are sending a simple test application to you. Please give it a try and let us know how it works at your side.

Looking forward for your reply.


All the best,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ronald Evers
Top achievements
Rank 1
answered on 22 Apr 2010, 08:10 AM
Hi Ivan,

Thank you for your effort. I upgraded to the retail version of Silverlight 4 and Visual Studio yesterday and the issue seems to be completely fixed. Your code was helpful in understanding the workings of the control more though.
So yeah issue is fixed, thanks for your help.
0
Pete
Top achievements
Rank 1
answered on 19 Apr 2011, 12:07 PM
I have the same problem using a listbox in a RadSplitButton. I am using the latest version of Silverlight and Q1 2011 Silverlight controls.
0
Petar Mladenov
Telerik team
answered on 22 Apr 2011, 08:19 AM
Hello XamlmaX,

We are not aware of such existing issue. Could you please elaborate more on your scenario? Any code snippet would also be highly appreciated since this way we could test this more faster and provide with a better advice or solution?

Best wishes,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pete
Top achievements
Rank 1
answered on 26 Apr 2011, 10:40 AM
I think we have fixed the issue now. We are using a viewlocator to a join our viewmodels and views and we are now caching the views.
Tags
Navigation
Asked by
Ronald Evers
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Ronald Evers
Top achievements
Rank 1
Pete
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or