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
50
TabItem Headerstyle gone after instantiation a TabItem from a file
posted
Hi - when I add a Tab to my xamribbon like this Dim StandardTab As New RibbonTabItemStandardTab.Header = "Standard RibbonTab works fine"myMainMenu.Tabs.Add(StandardTab) Xamribbon works as expected and the TabHeader inherits thestyle according to my Xamribbon Theme setting (Onyx) The problem occurs when I instantiate a tab from a alreadyexisting tabitem (I've written in a separate xaml file) andadd it to the xamribbon. Dim AdressesTab As New AdressenRibbonTabAdressesTab.Header = "problem tab from a xaml file"myMainMenu.Tabs.Add(AdressesTab) Now the TabHeader style one expects from Theme "onyx" isgone. 

Any help is welcome!

 

by

Hannes

Maybe this could be a PEBTAC-Problem :-)

(problem exists between terminal and chair)

**************BEGIN XamRibbon**************
<igRibbon:XamRibbonWindow
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:igRibbon="http://infragistics.com/Ribbon"
  xmlns:igDock="http://infragistics.com/DockManager"
  xmlns:igEditors="http://infragistics.com/Editors"
  xmlns:igWindows="http://infragistics.com/Windows"
  xmlns:s="clr-namespace:System;assembly=mscorlib"
  xmlns:locCtls="clr-namespace:HASIsys.SampleContent.DockManagerSampleContent;assembly=Infrastructure"      
  x:Class="Shell"
  Title="InfoSys"
  Width="Auto"
  Height="Auto"
  Background="#00FFFFFF"
  VerticalAlignment="Top"
  >
    <igRibbon:RibbonWindowContentHost>
        <igRibbon:RibbonWindowContentHost.Ribbon>
            <igRibbon:XamRibbon x:Name="RibbonMainMenuLayout"
  VerticalAlignment="Top" Theme="Onyx"     >
                <igRibbon:XamRibbon.Tabs>                   
                    <igRibbon:RibbonTabItem Header="Insert">
                        <igRibbon:RibbonGroup Id="ClipArt" Caption="Clip Art" />
                    </igRibbon:RibbonTabItem>
                </igRibbon:XamRibbon.Tabs>
            </igRibbon:XamRibbon>
        </igRibbon:RibbonWindowContentHost.Ribbon>
......
************** END XamRibbon**************

**************BEGIN TABITEM**************
<igRibbon:RibbonTabItem x:Class="AdressenRibbonTab"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:igRibbon="http://infragistics.com/Ribbon"
  xmlns:s="clr-namespace:System;assembly=mscorlib"
                         
  >
      
    <!-- RibbonGroup-->
    <igRibbon:RibbonGroup Id="Adresse" Caption="bearbeiten">
        <!-- Add a HorizontalWrapPanelTool to position your tools horizontally in this RibbonGroup. -->
        <igRibbon:ToolHorizontalWrapPanel>
            <igRibbon:ButtonTool
                                Caption="Neu"
                                igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge"
                                SmallImage="/Infrastructure;Component/Images/Icons/Ribbon/add16.png"
                                LargeImage="/Infrastructure;Component/Images/Icons/Ribbon/add32.png"/>
            <!-- Build a series of ButtonGroups that are pertinent to this Clipboard RibbonGroup.
                Then add simple Buttons as placeholders for visual reference. -->
            <igRibbon:ButtonGroup>
                <igRibbon:ButtonTool
                                Caption="Löschen"
                                igRibbon:RibbonGroup.MaximumSize="ImageAndTextNormal"
                                SmallImage="/Infrastructure;Component/Images/Icons/Ribbon/remove16.png"
                                LargeImage="/Infrastructure;Component/Images/Icons/Ribbon/remove32.png"/>
                <!--<Button Content="{x:Static ApplicationCommands.Cut}" />
                                    <Button Content="{x:Static ApplicationCommands.Copy}" />-->
            </igRibbon:ButtonGroup>
            <igRibbon:ButtonGroup>
                <igRibbon:ButtonTool
                                Caption="Löschen"
                                igRibbon:RibbonGroup.MaximumSize="ImageAndTextNormal"
                                SmallImage="/Infrastructure;Component/Images/Icons/Ribbon/ArrowLeft16.png"
                                LargeImage="/Infrastructure;Component/Images/Icons/Ribbon/ArrowLeft32.png"/>
                <igRibbon:ButtonTool
                                Caption="Löschen"
                                igRibbon:RibbonGroup.MaximumSize="ImageAndTextNormal"
                                SmallImage="/Infrastructure;Component/Images/Icons/Ribbon/ArrowRight16.png"
                                LargeImage="/Infrastructure;Component/Images/Icons/Ribbon/ArrowRight32.png"/>
                <!--<Button Content="{x:Static ApplicationCommands.Undo}" />
                                    <Button Content="{x:Static ApplicationCommands.Redo}" />-->
            </igRibbon:ButtonGroup>
        </igRibbon:ToolHorizontalWrapPanel>
    </igRibbon:RibbonGroup>
    <!-- End RibbonGroup-->
    <!-- RibbonGroup-->
    <igRibbon:RibbonGroup Id="KontaktAuswahl" Caption="auwählen">
        <igRibbon:MenuTool
                                ShouldDisplayGalleryPreview="False"
                                Caption="Kontakt"
                                LargeImage="/Infrastructure;Component/Images/Icons/Ribbon/Mann32.png"
                                SmallImage="/Infrastructure;Component/Images/Icons/Ribbon/Mann16.png">
            <igRibbon:MenuTool.ToolTip>
                <igRibbon:XamRibbonScreenTip                   
                                        Header="Kontaktauwahl"
                                        Footer="Kunde, Interessent oder Lieferant"
                                        FooterSeparatorVisibility="Visible"
                                        Content="Wählen Sie den gewünschten KontaktTyp aus."/>
            </igRibbon:MenuTool.ToolTip>
            <igRibbon:GalleryTool Id="presetsGallery" ItemBehavior="StateButton">
                <igRibbon:GalleryTool.Groups>
                    <igRibbon:GalleryItemGroup Title="Kontakttypen">
                        <igRibbon:GalleryItemGroup.ItemKeys>
                            <s:String>Interessent</s:String>
                            <s:String>Kunde</s:String>
                            <s:String>Lieferant</s:String>
                        </igRibbon:GalleryItemGroup.ItemKeys>
                    </igRibbon:GalleryItemGroup>
                </igRibbon:GalleryTool.Groups>
                <igRibbon:GalleryTool.Items>

                    <igRibbon:GalleryItem Key="Interessent" Text="Interessent"
                                        Image="/Infrastructure;Component/Images/Icons/Ribbon/Interessent48.png"
                                        Tag="Times New Roman;11.0;0,0,0;Normal"/>

                    <igRibbon:GalleryItem Key="Kunde" Text="Kunde"
                                        Image="/Infrastructure;Component/Images/Icons/Ribbon/Kunde48.png"
                                        Tag="Times New Roman;11.0;0,0,0;Normal"/>

                    <igRibbon:GalleryItem Key="Lieferant" Text="Lieferant"
                                        Image="/Infrastructure;Component/Images/Icons/Ribbon/Lieferant48.png"
                                        Tag="Times New Roman;11.0;0,0,0;Normal"/>
                </igRibbon:GalleryTool.Items>
            </igRibbon:GalleryTool>
        </igRibbon:MenuTool>
    </igRibbon:RibbonGroup>
</igRibbon:RibbonTabItem>
**************END TABITEM**************
Parents
No Data
Reply
  • 54937
    Verified Answer
    Offline posted

    In WPF, the key used for obtaining a local Style is always the type of the class (regardless of the DefaultStyleKey). So by deriving from RibbonTabItem, you are causing WPF to look for a local Style for your derived class - AdressenRibbonTab. Since there are no local styles with that as its TargetType, WPF doesn't find a local style and only ends up using the generic theme Style. So instead of defining a derived RibbonTabItem, you should just define a xaml file for the RibbonTabItem (i.e. create a xaml file, copy the contents of the current file you have and remove the x:Class - or just remove the x:Class and delete the backing .cs file) and then use Application.LoadComponent to create the RibbonTabItem instance.

    e.g.

    RibbonTabItem tab = Application.LoadComponent(new Uri("AdressenRibbonTab.xaml",UriKind.Relative )) as RibbonTabItem;

Children