Aniruddha Acharya

Aniruddha Acharya

  • NA
  • 304
  • 20.6k

Icon images binding issue for Menu Item template in WPF

Nov 16 2021 12:16 PM

Hi,

How to  bind  multiple MenuItem icon images in single controltemplate .

Not Showing  multiple menuitems images 

Source="{Binding Icon}"  it's not working in template

I am using this code :

<Menu IsMainMenu="True">
 <MenuItem Header="_Admin" Template="{DynamicResource VsOnline}" Icon="../Images/Admin.jpg">
 <MenuItem Header="_Sale" Template="{DynamicResource VsOnline}" Icon="../Images/Sale.jpg">
 <MenuItem Header="_Products" Template="{DynamicResource VsOnline}" Icon="../Images/Product.jpg">
</Menu>
<ControlTemplate x:Key="VsOnline" TargetType="MenuItem">
    <Border x:Name="bdrMenu" BorderThickness="0,0,0,1" BorderBrush="#FF0078D7">
        <StackPanel TextBlock.FontSize="15px" Height="60" Orientation="Horizontal" Background="#FF363676">
            <StackPanel Orientation="Vertical">
                <Image VerticalAlignment="Top" HorizontalAlignment="Left" Source="{Binding Icon}" Height="25" Margin="15,5,5,0" />
                <Label x:Name="lblMenu" Content="{TemplateBinding Header}" Margin="5,0,5,5" Width="150" Foreground="White" />
            </StackPanel>                              
        </StackPanel>
    </Border>       
</ControlTemplate>

Answers (1)