C1Menu with C1Theme with unexpected appearance

Posted by: lutz.boscher on 9 September 2019, 12:18 am EST

    • Post Options:
    • Link

    Posted 9 September 2019, 12:18 am EST

    Hi

    We are using in our application the theme C1ThemeOffice2016DarkGray. On the mainwindow we have a C1Menu with some menuitems. Some menuitems are disabled for the user.

    I have attached a demoapplication with two C1Menus, one has fixed items, and the second simulated the creation of menuitems at startup.

    When I omit the c1:C1Menu.ItemContainerStyle it works fine, the foreground is white, but otherwise, the foreground is black and when I move the mouse over the mainmenu, it becomes a darkredbackground.

    It works also, when I use another theme, e.g. C1ThemeOffice2016White.

    What can I do to show a correct menu with the specific theme.

    Lutz Boscher

    WMSThemeDemoApp.zip

  • Posted 9 September 2019, 7:25 pm EST

    Hi Lutz,

    Thank you for sharing the sample application. I could observe the behavior too. It seems to be a bug so, I have escalated the case to the concerned development team(ID: 397533) and will inform you as soon as I hear from them.

    Regards,

    Basant

  • Posted 12 September 2019, 3:37 pm EST

    Hi Lutz,

    Developer replied as follows:

    When we use C1Menu.ItemContainerStyle, we are creating our own style for C1MenuItem inside C1Menu and hence it doesn’t follow the applied theme anymore. So, In order to avoid using ItemContainerStyle for enabling/disabling a menu item you can directly use C1MenuItems in your binding source instead of creating custom MenuItem :

    CodeBehind:

    public ObservableCollection<C1MenuItem> MenuItem
    {
      get { return (ObservableCollection<C1MenuItem>)GetValue(MenuItemProperty); }
      set { SetValue(MenuItemProperty, value); }
    }
    
    private void MainWindow_Loaded(object sender, RoutedEventArgs e) 
    {
     var subMenuItem = new C1MenuItem() 
     {
      Header = "File",
      IsEnabled = true
     };
    
     subMenuItem.Items.Add(new C1MenuItem()
     {
      Header = "Header 2 1",
      IsEnabled = true
     });
     subMenuItem.Items.Add(new C1MenuItem()
     {
      Header = "Header 2 2",
      IsEnabled = true 
     });
     subMenuItem.Items.Add(new C1MenuItem()
     {
      Header = "Header 2 2",
      IsEnabled = true
     });
     subMenuItem.Items.Add(new C1MenuItem()
     {
      Header = "Header 2 2",
      IsEnabled = false
     });
    
    
     MenuItem = new ObservableCollection<C1MenuItem>()
     {
      subMenuItem,
     };
    }
    

    XAML:

    <c1:C1Menu c1:C1DockPanel.Dock="Top" ItemsSource="{Binding MenuItem}" x:Name="menu2"  Height="30" FontSize="12" FontFamily="Verdana">
      <c1:C1Menu.ItemTemplate>
        <c1:C1HierarchicalDataTemplate DataType="{x:Type c1:C1MenuItem}" ItemsSource="{Binding Path=Items}">
          <TextBlock Text="{Binding Header}"  />
        </c1:C1HierarchicalDataTemplate>
      </c1:C1Menu.ItemTemplate>
    </c1:C1Menu>
    

    Hope this will help you. However, please let us know if there is some specific need to use custom MenuItem?

    Regards,

    Basant

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels