Coffeehouse Thread

21 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

WPF: One thing that bothers me...

Back to Forum: Coffeehouse
  • User profile image
    littleguru

    ... is that I haven't seen the controls in WPF using the skin that is applied on Windows XP. Is there a way to make them look like a normal Windows application? I mean skinned etc. Did I only not know how to apply the Windows skin or are WPF apps looking like old Win98/2000 application and I need to make my own skinned button/checkbox/listbox/...?

    I have only seen that every application done with WPF looks different: Expressions is different then Max etc. This is very very frustrating: WPF should provide a set of controls that look skinned - I mean provide them out of the box.

    Why are the normal controls not skinned? Is this planned for the final version?

    Edit: I know I can do everything on my own, but this should be something that comes with the framework.

  • User profile image
    andokai

    What CTP and what skin are you using?

    Prior to the February CTP a Royale skin was not included. This has been sorted now, although the toolbar's colouring still looks a little strange.

  • User profile image
    littleguru

    I was using the Feb CTP. Perhaps I simply don't know how to apply a skin: could you explain me how that works?

    If I'm using a custom skin, is that also supported? I mean I have my own special-something skin applied on Windows XP. Do the controls of the WPF then look also like the Windows XP controls?

  • User profile image
    footballism

        I have to say I am also quite confused with the WPF's theme system, it obviously that WPF ships with several version of PresentationFramework.dll, for instance PresentationFramework.Luna.dll, PresentationFramework.Classic.dll,  PresentationFramework.Royale.dll, PresentationFramework.Aero.dll, but it seems that only the PresentationFramework.Classic.dll will be used by default, and there is no sample or reference in the documentation about how to change the theme of the WPF controls, and how to use the WPF built-in themes.
        But one amazing thing WPF enables us is that you can define your custom theme, and apply it at runtime very easily, and Chaz have shown us how to do it in this blog, probably this is what you want...

    Sheva

  • User profile image
    littleguru

    This is not exactly what I was looking for. I want to apply the skin that is applied on my Windows XP. Not a custom skin, but thank you for the sample, it's cool.

  • User profile image
    littleguru

    Well I understood now, how this thing works... If I have applied one of the skins that are supported by WPF they are applied automatically. But if I have a custom made skin it does not work... Hmmm... That is really bad, because all the custom skins do not work. Hopefully MS creates something to make all skins work.

  • User profile image
    andokai

    littleguru wrote:
    Well I understood now, how this thing works... If I have applied one of the skins that are supported by WPF they are applied automatically. But if I have a custom made skin it does not work... Hmmm... That is really bad, because all the custom skins do not work. Hopefully MS creates something to make all skins work.


    You see the problem lies in the fact that WPF doesn't render the same way. Skins in Windows are bitmap based while on WPF they're vector based. WPF doesn't actually use the theme on your computer just uses one of the WPF themes that has the same name as the one currently in use and defaults to classic emulation if it can't find one.

  • User profile image
    footballism

    littleguru wrote:
    This is not exactly what I was looking for. I want to apply the skin that is applied on my Windows XP

    So you want your application to have luna look and feel?

    This is something which I also want to know:)

    Sheva

  • User profile image
    footballism

    andokai wrote:

       WPF doesn't actually use the theme on your computer just uses one of the WPF themes that has the same name as the one currently in use and defaults to classic emulation if it can't find one.

    So you mean when my OS has Luna theme applied, WPF will use PresentationFramework.Luna.dll instead of default PresentationFramework.Classic.dll. but the reaility is the opposite.

    BTW: Do you know how to programmatically manipulate the built-in themes of WPF?

    Sheva

  • User profile image
    andokai

    footballism wrote:

    So you mean when my OS has Luna theme applied, WPF will use PresentationFramework.Luna.dll instead of default PresentationFramework.Classic.dll. but the reaility is the opposite.


    That's exactly what should happen. Are you saying your controls still appear in Classic mode when running Luna or Royale?

    footballism wrote:

    BTW: Do you know how to programmatically manipulate the built-in themes of WPF?


    I haven't tried to be honest.

  • User profile image
    littleguru

    I'm running "Slate". A custom skin. The window is skinned, but the buttons and controls aren't! Why is WPF not taking the bitmaps of the skin and stick it on the button... WPF is able to render bitmaps, isn't it?

  • User profile image
    andokai

    Yes it it but it doesn't render controls using bitmaps. Otherwise you're defeating the whole point of a vector based UI.

  • User profile image
    Khamul

    I posted the Royale bug on Connect (and while I didn't do any searches, I bet I wasn't the only one!) - didn't realise they'd gotten 'round to fixing the thing.

    Why can't WPF just pull the colours from the .Net 2.0 System.Drawing.SystemColors class or something similiar? Surely it would be easy to programmatically alter the Vector color make up? The lack of third party theme support is what has me still using WinForms as my main development tool (and when I say development, I'm a High School student, I don't do this thing as a profession, or even as part as school - I do it for the fun!!!, so don't shoot me for considering the use of betas in mainstream).

  • User profile image
    littleguru

    andokai wrote:
    Yes it it but it doesn't render controls using bitmaps. Otherwise you're defeating the whole point of a vector based UI.


    Well for compatibility they could render the controls by glueing the bitmaps on the buttons. Just for the skins that are not supported out of the box. And just to keep a consistent look in the applications. We have already (when having applied a theme) two different types of apps:

    skinned,
    old win32 apps

    and now we get also a thirth:

    partially skinned wpf apps (the window itself is skinned).

  • User profile image
    footballism

    Khamul wrote:

        Why can't WPF just pull the colours from the .Net 2.0 System.Drawing.SystemColors class or something similiar?

        In WPF, there is a class called System.Windows.SystemColors which is an equivalent to System.Drawing.SystemColors class.

    Khamul wrote:

        Surely it would be easy to programmatically alter the Vector color make up? The lack of third party theme support is what has me still using WinForms as my main development tool.

        There is no brainer that WPF controls except Window don't support third party themes, because all WPF controls's rendering are passed to milcore.dll, and then are eventually rendered by Direct3D down the road. but there is an exception, that is the System.Windows.Window's chrome is still rendered by GDI, that's why the Window can still support third party themes.  I think the reason why Microsoft decides to render Window chrome in GDI is pretty straightword, that is backward compatibility.
        But there is one thing which I am really really confused here, because even if the WPF controls don't support third party themes, they also don't support Windows built in themes(Luna and Royale). if you look at the WPF Button control's ControlTemplate content closely, you will find that only the classic theme(highlighted in red colour) is used there:

    <?xml version="1.0" encoding="utf-16"?>
    <ControlTemplate
        TargetType="ButtonBase" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib">
        <mwt:ClassicBorderDecorator
            BorderBrush="{TemplateBinding Border.BorderBrush}"
            BorderStyle="Raised"
            BorderThickness="{TemplateBinding Border.BorderThickness}"
            Name="ContentContainer"
            Background="{TemplateBinding Panel.Background}">
            <ContentPresenter
                Margin="{TemplateBinding Control.Padding}"
                HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
                Name="ContentSite"
                VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
                ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
                RecognizesAccessKey="True"
                Content="{TemplateBinding ContentControl.Content}" />
        </mwt:ClassicBorderDecorator>
        <ControlTemplate.Triggers>
            <Trigger
                Property="UIElement.IsKeyboardFocused">
                <Trigger.Value>
                    <s:Boolean>True</s:Boolean>
                </Trigger.Value>
                <Setter
                    Property="mwt:ClassicBorderDecorator.BorderStyle"
                    TargetName="ContentContainer"
                    Value="{x:Static mwt:ClassicBorderStyle.RaisedFocused}" />
            </Trigger>
            <Trigger
                Property="Button.IsDefaulted">
                <Trigger.Value>
                    <s:Boolean>True</s:Boolean>
                </Trigger.Value>
                <Setter
                    Property="mwt:ClassicBorderDecorator.BorderStyle"
                    TargetName="ContentContainer"
                    Value="{x:Static mwt:ClassicBorderStyle.RaisedFocused}" />
            </Trigger>
            <Trigger
                Property="ButtonBase.IsPressed">
                <Trigger.Value>
                    <s:Boolean>True</s:Boolean>
                </Trigger.Value>
                <Setter
                    Property="mwt:ClassicBorderDecorator.BorderStyle"
                    TargetName="ContentContainer"
                    Value="{x:Static mwt:ClassicBorderStyle.RaisedPressed}" />
            </Trigger>
            <Trigger
                Property="ToggleButton.IsChecked">
                <Trigger.Value>
                    <s:Boolean>True</s:Boolean>
                </Trigger.Value>
                <Setter
                    Property="mwt:ClassicBorderDecorator.BorderStyle"
                    TargetName="ContentContainer"
                    Value="{x:Static mwt:ClassicBorderStyle.RaisedPressed}" />
            </Trigger>
            <Trigger
                Property="UIElement.IsEnabled">
                <Trigger.Value>
                    <s:Boolean>False</s:Boolean>
                </Trigger.Value>
                <Setter
                    Property="TextElement.Foreground"
                    Value="{DynamicResource {SystemResourceKey}}" />
            </Trigger>
            <Trigger
                Property="FrameworkElement.Width">
                <Trigger.Value>
                    <s:Double>NaN</s:Double>
                </Trigger.Value>
                <Setter
                    Property="FrameworkElement.MinWidth">
                    <Setter.Value>
                        <s:Double>75</s:Double>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger
                Property="FrameworkElement.Height">
                <Trigger.Value>
                    <s:Double>NaN</s:Double>
                </Trigger.Value>
                <Setter
                    Property="FrameworkElement.MinHeight">
                    <Setter.Value>
                        <s:Double>23</s:Double>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    This is only the Button's ControlTemplate definition, but I believe all other WPF controls also have the ControlTemplates defined in the same way as the Button control.

        So my question comes, how to redefine the WPF Controls' ControlTemplates so that we can use PresentationFramework.Luna.dll or PresentationFramework.Royale.dll instead of the default PresentationFramework.Classic.dll?
        I believe WPF should provide a mechanism in which the WPF application can read the Windows Operating System's theme information, and dynamically change the look and feel accordingly rather than always using the classic look and feel. but even if WPF provide the aforementioned mechanism, this mechanism undoutedly will only support the Windows built in themes, if you want the third party theme say Luna Element to be supported, you should provde a PresentatioFramework.LunaElement.dll or something like:)

    Sheva

  • User profile image
    footballism

    Wait a minute, I should correct some portion of my previous post, because I use the Luna Element theme for a long lomg time, which makes me believe that my current theme is the built in windows theme. when I change the theme to Luna, all the WPF controls have Luna theme applied automatically:P

    For all other parts of my post, it should be of no error:P

    Sheva

  • User profile image
    andokai

    Aw I was just about to go into detail about how you were wrong. Big Smile

    Glad you got it sorted, happy St. Patrick's Day.

  • User profile image
    footballism

    andokai wrote:

    Aw I was just about to go into detail about how you were wrong.

    When you use a thing for really a long time, you will always take it for granted, that's why I mistakenly take Luna Element theme as the default theme:P

    Sheva

    andokai wrote:

    Glad you got it sorted, happy St. Patrick's Day.

    What's St. Patrick's Day?:O

    Sheva

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.