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

RadMenuItem Icons in Q3

8 Answers 212 Views
Menu
This is a migrated thread and some comments may be shown as answers.
roger
Top achievements
Rank 1
roger asked on 12 Nov 2010, 06:00 PM
Hey everyone

Did anybody the following error?

When updating from Q2 to Q3, the RadMenuItems nolonger display the icon but rather the actual text inside Icon="..".

Thanks for your info!

8 Answers, 1 is accepted

Sort by
0
roger
Top achievements
Rank 1
answered on 13 Nov 2010, 02:31 PM
Could a mod please move this in the right (RadMenuItem) forum? :-)
0
Accepted
Konstantina
Telerik team
answered on 15 Nov 2010, 12:08 PM
Hello Roger,

Thank you for contacting us.

In order to enable the display of a text in the icon space, we had to change the Icon property behaviour. To display an Image for an Icon you will have to define the IconTemplate property, as follows:

<telerik:RadMenuItem Header="Item 1">
        <telerik:RadMenuItem.IconTemplate>
             <DataTemplate>
                  <Image Source="/Desert.jpg" Height="16" Width="16"/>
             </DataTemplate>
        </telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>

Sorry for the caused inconvenience.

Please let us know if you have further questions.

All the best,
Konstantina
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
Roberto Vercelli
Top achievements
Rank 1
answered on 16 Nov 2010, 02:52 PM
Hi!
I followed these instructions but it's not working to me. Probably this happens because I'm using the context menu inside a treeview datatemplate: 

<UserControl x:Class="MyProject.Controls.Test"
    mc:Ignorable="d"
    xmlns:telerikRibbonBar="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.RibbonBar"
    xmlns:telerikDocking="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"            
    d:DesignHeight="300" d:DesignWidth="400">
     
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadOutlookBar>
            <telerik:RadOutlookBar.Items>
                <telerik:RadOutlookBarItem Header="outlook1" />
                <telerik:RadOutlookBarItem Header="outlook2" />
                <telerik:RadOutlookBarItem Header="outlook3" />
            </telerik:RadOutlookBar.Items>
            <telerik:RadOutlookBar.ContentTemplate>
                <DataTemplate>
                    <telerik:RadTreeView>
                        <telerik:RadTreeViewItem Header="item1"/>
                        <telerik:RadTreeViewItem Header="item2"/>
                        <telerik:RadTreeViewItem Header="item3"/>
                        <telerik:RadContextMenu.ContextMenu>
                            <telerik:RadContextMenu>
                                <telerik:RadMenuItem Header="menu1">
                                    <telerik:RadMenuItem.IconTemplate>
                                        <DataTemplate>
                                            <Image Source="/Desert.jpg" Height="16" Width="16"/>
                                        </DataTemplate>
                                    </telerik:RadMenuItem.IconTemplate>
                                </telerik:RadMenuItem>
                                <telerik:RadMenuItem Header="menu2">
                                    <telerik:RadMenuItem.IconTemplate>
                                        <DataTemplate>
                                            <Image Source="/Desert.jpg" Height="16" Width="16"/>
                                        </DataTemplate>
                                    </telerik:RadMenuItem.IconTemplate>
                                </telerik:RadMenuItem>                                   
                                <telerik:RadMenuItem Header="menu3">
                                    <telerik:RadMenuItem.IconTemplate>
                                        <DataTemplate>
                                            <Image Source="/Desert.jpg" Height="16" Width="16"/>
                                        </DataTemplate>
                                    </telerik:RadMenuItem.IconTemplate>
                                </telerik:RadMenuItem>                                   
                            </telerik:RadContextMenu>
                        </telerik:RadContextMenu.ContextMenu>
                    </telerik:RadTreeView>
                </DataTemplate>
            </telerik:RadOutlookBar.ContentTemplate>
        </telerik:RadOutlookBar>
    </Grid>
</UserControl>

Another note: I also have a grid in the control with a context menu. In this case I'm not define any template and the icons are correctly visible in the context menu. Amazingly if I open the grid context menu and I see the icons, they start to appear in the tree context menu as well. 

Last question: what is the correct way to set the Icon in the ContainerBindings for the context menu? 
0
roger
Top achievements
Rank 1
answered on 17 Nov 2010, 12:55 PM
Worked for me.

Thanks Konstantina.
0
Konstantina
Telerik team
answered on 18 Nov 2010, 10:00 AM
Hello Roberto,

I tried your sample code, and the icons are displayed as expected. Please check again if the path of the file of the Images is correct.

If you still experience difficulties please send us a sample project in which we can observe the issue. In that way we will be able to track down the source of the problem.

Regards,
Konstantina
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Roberto Vercelli
Top achievements
Rank 1
answered on 22 Nov 2010, 05:42 PM
I probably found the issue. 
If in the APP.XAML.CS file i write this in the InitializeRootVisual:

protected virtual void InitializeRootVisual()
{
    Grid grid = new Grid();
    grid.Children.Add(new TestControl());
    this.RootVisual = grid;
}

the icons are not shown. Please notice I need this piece of code as a workaround for my own controls. 

Roberto
0
DenisCL
Top achievements
Rank 1
answered on 23 Nov 2010, 06:54 PM
I have a problem with latest internal builds (hotfix) :
Work well :
<telerikNav:RadMenuItem>
<telerikNav:RadMenuItem.Icon>
        <Image Source="/Genapi.iNova.WebUI.Silverlight.Formalites;component/img/ENRE.png" />
</telerikNav:RadMenuItem.Icon>
</telerikNav:RadMenuItem>

But when I set the image in a a resource :
In resources :
<Image Source=
"/Genapi.iNova.WebUI.Silverlight.Formalites;component/img/ENRE.png" x:Key="ENREimg2"/>
 Then :
<telerikNav:RadMenuItem Icon="{StaticResource ENREimg2}" />
I've a measure exception... This is reproduceable in the simple app.
à MS.Internal.XcpImports.CheckHResult(UInt32 hr)
à MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
à System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
à System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)


Did you have any tips for me ?

Additionaly, I've another problem like this, when using IconTemplate property. I've send the datatemplate to resources, but when I try to apply then to the RadMenuItem, I didn't have images... But I'm not able to reproduce it on a buttonApp....
0
Konstantina
Telerik team
answered on 24 Nov 2010, 11:51 AM
Hello,

I will comment on each of your issues.

First, Denis, in Silverlight putting a Control (or an Image) in Resource and then use it to put it into the VisualTree is not possible.
Roberto, could you please create a sample application in which this issue can be observed. In that way we will be able to track down the source of the problem and fix it.

Looking forward to your reply.

Regards,
Konstantina
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
Menu
Asked by
roger
Top achievements
Rank 1
Answers by
roger
Top achievements
Rank 1
Konstantina
Telerik team
Roberto Vercelli
Top achievements
Rank 1
DenisCL
Top achievements
Rank 1
Share this question
or