RadMenuItem Icons in Q3

9 posts, 1 answers
  1. roger
    roger avatar
    24 posts
    Member since:
    Jun 2009

    Posted 12 Nov 2010 Link to this post

    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!
  2. roger
    roger avatar
    24 posts
    Member since:
    Jun 2009

    Posted 13 Nov 2010 Link to this post

    Could a mod please move this in the right (RadMenuItem) forum? :-)
  3. DevCraft banner
  4. Answer
    Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 15 Nov 2010 Link to this post

    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
  5. Roberto Vercelli
    Roberto Vercelli avatar
    3 posts
    Member since:
    May 2010

    Posted 16 Nov 2010 Link to this post

    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? 
  6. roger
    roger avatar
    24 posts
    Member since:
    Jun 2009

    Posted 17 Nov 2010 Link to this post

    Worked for me.

    Thanks Konstantina.
  7. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 18 Nov 2010 Link to this post

    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
  8. Roberto Vercelli
    Roberto Vercelli avatar
    3 posts
    Member since:
    May 2010

    Posted 22 Nov 2010 Link to this post

    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
  9. DenisCL
    DenisCL avatar
    69 posts
    Member since:
    Dec 2009

    Posted 23 Nov 2010 Link to this post

    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....
  10. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 24 Nov 2010 Link to this post

    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
Back to Top
DevCraft banner