Converting to 2011.2 , replace RibbonStyles with SharedResourceKeys ?

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 5 years ago by Lyon Gu
Version: 13.2.0592
Avatar

In version 2011.2, How can I get the exactly apperance of using "RibbonStyles.ComboBoxKey" ?

Comments (12)

Answer - Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

In 2013.2, you would use this style on a ComboBox:

<ComboBox Style="{DynamicResource {x:Static themes:SharedResourceKeys.ComboBoxStyleKey}}"> />

Whereas in 2011.2, you would use this style:

<ComboBox Style="{DynamicResource {x:Static ribbon:RibbonStyles.ComboBoxKey}}" />

Either of those will style the ComboBox using our themes.  Note that if you are using 2013.2, please see the documentation on Themes since some additional setup in the app startup code is needed for Office and Metro themes.


Actipro Software Support

Posted 5 years ago by Lyon Gu
Avatar

Thank you for your answer.Sorry for the delay.

As you kown, in 2011.1,I would use this:

<ComboBox Style="{DynamicResource {x:Static ribbon:RibbonStyles.ComboBoxKey}}" />

 

But in 2011.2,you had removed the RibbonStyles. In the documentation ,"The RibbonStyles and it's associated keys and styles were removed since all native control styles formerly provided by that class are now provided via SharedResourceKeys, often with new options and improved looks."Right?

So I refered the Upgrade Instructions, then I use this:

<ComboBox Style="{DynamicResource {x:Static themes:SharedResourceKeys.ComboBoxStyleKey}}"> />

 But it doesn't work.What's my problem?

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

I would think that would work, but note that it will use whichever Actipro theme you have set in our ThemeManager.  And also note that if you want an Office or Metro theme, those require a couple additional registration steps to be done in the app startup.  All this is explained in the documentation topics for Actipro Themes, including how to register themes and how to set the current theme.


Actipro Software Support

Posted 5 years ago by Lyon Gu
Avatar

Hi,code talks:

public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            RibbonThemeCatalogRegistrar.Register();
            ThemeManager.CurrentTheme = ThemeName.AeroNormalColor.ToString();
            base.OnStartup(e);
        }
    }

 

<ComboBox x:Name="RibbonStyleCB" Width="100"
                  Height="20"
                  Style="{DynamicResource {x:Static themes:SharedResourceKeys.ComboBoxStyleKey}}">
            <ComboBoxItem>item1</ComboBoxItem>
            <ComboBoxItem>item2</ComboBoxItem>
            <ComboBoxItem>item3</ComboBoxItem>
            <ComboBoxItem>item4</ComboBoxItem>
        </ComboBox>

        <ComboBox x:Name="NativeStyleCB"
                  Width="100"
                  Height="20">
            <ComboBoxItem>item1</ComboBoxItem>
            <ComboBoxItem>item2</ComboBoxItem>
            <ComboBoxItem>item3</ComboBoxItem>
            <ComboBoxItem>item4</ComboBoxItem>
        </ComboBox>

 

 Now RibbonStyleCB's appearance is same as NativeStyleCB.

Did I forget something?

[Modified 5 years ago]

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Lyon,

They should have a similar appearance based on the code you submitted.  You are setting an Aero theme for your app so all the Actipro styles will have that theme.  Perhaps you are looking for something more like SharedResourceKeys.ToolBarEmbeddedComboBoxStyleKey, which is still in the Aero style but designed more for usage within a toolbar-like scenario?


Actipro Software Support

Posted 5 years ago by Lyon Gu
Avatar

Hi, thank you.SharedResourceKeys.ToolBarEmbeddedComboBoxStyleKey is I wanted.

But there is any documentation about Ribbon Style keys in 2011.2 correspond to the keys in 2011.1?

Like:

V2011.1                                                                V2011.2

ribbon:RibbonStyles.TextBoxKey                           ?

ribbon:RibbonStyles.CheckBoxKey                       ?

ribbon:RibbonStyles.PasswordBoxKey                 ?

ribbon:RibbonStyles.ToolTipKey                             ?  

ribbon:RibbonStyles.RadioButtonKey                     ?

...

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

There isn't a mapping but you can look at the SharedResourceKey class members list in the documentation to see all the options.  They are named very well so it's easy to determine which style to use for which scenario.


Actipro Software Support

Posted 5 years ago by Lyon Gu
Avatar

Maybe I made a mistake.My question is : If I follow these two steps,

Step 1:

public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            RibbonThemeCatalogRegistrar.Register();
            ThemeManager.CurrentTheme = ThemeName.AeroNormalColor.ToString();
            base.OnStartup(e);
        }
    }

 Step 2:

<ComboBox x:Name="RibbonStyleCB" Width="100"
                  Height="20"
                  Style="{DynamicResource {x:Static themes:SharedResourceKeys.ComboBoxStyleKey}}">
            <ComboBoxItem>item1</ComboBoxItem>
            <ComboBoxItem>item2</ComboBoxItem>
            <ComboBoxItem>item3</ComboBoxItem>
            <ComboBoxItem>item4</ComboBoxItem>
        </ComboBox>

 can I get the combobox with Ribbon Style?

If the answer is no,what does ComboBoxStyleKey mean?Is it a native style?

Posted 5 years ago by Lyon Gu
Avatar

If not trouble,could you send me a demo? It's an easy one for you,I just want the same ribbon style in 2011.1.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

In the newer themes system, all the Actipro controls use a common set of brush resources so they consistently look good together.  You can have our themes update all native WPF controls in your app as well.

I think it sounds like you want Office themes?  You'd need to have a reference to the Office themes assembly and have code like this in your app's startup:

ThemesOfficeThemeCatalogRegistrar.Register();
ThemeManager.AreNativeThemesEnabled = true;  // If you want all native WPF controls themed by default... you can comment this out if not
ThemeManager.CurrentTheme = ThemeName.OfficeBlue.ToString();

You might want to start off with that middle line commented out and see if that gets you what you want.

For your other question, the ComboBoxStyleKey is just a resource key that refers to a Style we made for the ComboBox control.  If you have a ComboBox with that style (which happens automatically when you set ThemeManager.AreNativeThemesEnabled = true), it will be styled with whatever theme you set to ThemeManager.CurrentTheme.  So if all three lines above are run in the app startup, all your ComboBox controls will get an Office blue theme.  Same thing for Buttons, the Ribbon, etc.

If you want to embed a ComboBox in a Ribbon or ToolBar, you should use that other resource key we mentioned earlier in the thread instead, specifically on the desired ComboBox instances.  It applies a different themed Style, one for ComboBoxes that are embedded in toolbar-like controls.


Actipro Software Support

Posted 5 years ago by Lyon Gu
Avatar

Thank you for your demo and explanation.Really appreciate it.

Actually not Office themes.In 2011.1,I use these:

<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.ToolTipKey}}" />
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.TextBoxKey}}"/>
<Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.PasswordBoxKey}}" />
<Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.RadioButtonKey}}"/> 
ThemeManager.CurrentTheme = CommonThemeName.AeroNormalColor.ToString();

Now,how can I get the same styles in 2011.2?

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

All the styles we now have in the newer versions are provided in the keys in SharedResourceKeys.  There might not always be an exact style match for what there was in the old version though.  The various ToolBarEmbedded* ones such as for ComboBox and TextBox are probably more like what they were in the old 2011.1 version.


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 12 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.