Coffeehouse Thread

8 posts

Forum Read Only

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

Look-less WPF controls.

Back to Forum: Coffeehouse
  • User profile image
    fvuej

    I'm currently trying to create custom controls in WPF, and in reading articles and tutorials, they all have the catchphrase "look-less" in them. 
    Now I understand what WPF is trying to accomplish, but if WPF controls are truly look-less, then why does some of the controls have a background, foreground, border ...etc properties?
    Doesn't that imply that it does indeed have a look?
    Or maybe I'm just interpreting the term, look-less, incorrectly?

  • User profile image
    figuerres

     

    you are very right.

    the missing detail is that controls have a "default Style" built in that is used when you do not specify one.  normally that default "look" follows the other windows controls.

    this is done so that if you just want to get a basic form / window working you do not have to manually include a bunch of xaml style files.

    if they did not have a default style built in then using them would be confusing to many developers as you would not see anything untill you added some styles.

    I hope that clears things up a bit Smiley

  • User profile image
    fvuej

    @figuerres:Thanks for the response.

    What confuses me is why would countless articles preach for look-less controls, when the default WPF controls have look specific properties themselves? Shouldn't there be documentation instead, on how to change the default look through styling(xaml), instead of adding properties on the controls themselves?

    As someone who really wants to do things the right way, it seems as though Microsoft is saying, its okay to do things the opposite way of what Microsoft is saying...err, my brain hurts.


    Maybe I'm just over thinking this? 

  • User profile image
    AndyC

    @fvuej: Custom styles are supposed to hook into the value of properties, where it makes sense to do so. I think it was something of a trade-off between truly behavioural only controls, which would have required a much steeper learning curve, and traditional style controls.

  • User profile image
    vesuvius

    @fvuej: Think of it as a colouring book. When you get one, there are always a few examples already coloured in so you can see how it is done, you can copy these (i.e. use the default styles) or create your own

  • User profile image
    magicalclick

    @fvuej:

    http://www.codeproject.com/KB/WPF/podder2.aspx

    http://bea.stollnitz.com/blog/?p=40

    http://www.codeproject.com/KB/WPF/WPFCustomControl.aspx

    Look-less means, you can apply "template". If you cannot apply template, you know it is not look-less. In a sense, template is the "look" and template is a lot more powerful than setting the background color. The second link shows how much more powerful template it is compare to setting some basic properties of the control.

    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified
  • User profile image
    spivonious

    They put the common "look" properties in for convenience. Your control templates are free to ignore those properties.

  • User profile image
    wkempf

    In WPF controls are called look-less because the look isn't part of the control's implementation. The control only defines the behavior. The look is defined by a template that can be swapped out. A default template is defined for controls, because it wouldn't make any sense to force a selection here. IOW, there's a clean separation between the display and the behavior where templates define how things are displayed and the control defines how things behave.

Conversation locked

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