Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
Trouble with Icon in ApplicationMenu Using Dynamic Items from View Model
posted

Wit the following code I am getting text instead of an image in the Icon location.

 

In my ViewModel, I am exposing the Icon as a URI object, and have the following XAML code:

                                <igRibbon:XamRibbon.ApplicationMenu>
                                    <igRibbon:ApplicationMenu 
                                                Image="{Binding Path={x:Static vm:clsBaseGUIMenuViewModel.ApplicationIconPath}}"
                                                DataContext="{Binding Path={x:Static vm:clsBaseGUIViewModel.MenuViewModelPath}}"
                                                ItemsSource="{Binding Path={x:Static vm:clsBaseGUIMenuViewModel.AppMenuItemsPath}}">
                                        <igRibbon:ApplicationMenu.ItemContainerStyle>
                                            <Style TargetType="{x:Type igRibbon:ToolMenuItem}">
                                                <Setter Property="Header" Value="{Binding Path={x:Static vm:clsMenuItemViewModel.DisplayNamePath}}" />
                                                <Setter Property="Icon" Value="{Binding Path={x:Static vm:clsMenuItemViewModel.IconPath}}" />
                                                <Setter Property="Command" Value="{Binding Command}" />
                                            </Style>
                                        </igRibbon:ApplicationMenu.ItemContainerStyle>
                                    </igRibbon:ApplicationMenu>
                                </igRibbon:XamRibbon.ApplicationMenu>

 

Not sure what I am doing wrong, but help is appreciated.

 

  • 220
    Verified Answer
    posted

    Found the solution.

     

    Exposed the property in the ViewModel as an ImageSource and added a DataTemplate

     

                                    <igRibbon:XamRibbon.Resources>
                                        <DataTemplate DataType="{x:Type ImageSource}">
                                            <Image Source="{Binding}" />
                                        </DataTemplate>
                                    </igRibbon:XamRibbon.Resources>