These are chat archives for AvaloniaUI/Avalonia

19th
Feb 2015
José Manuel Nieto
@SuperJMN
Feb 19 2015 08:32
Thanks for the note :D
José Manuel Nieto
@SuperJMN
Feb 19 2015 10:16
yuck! I found a very strange behavior!
@grokys Please, check this. 2 silly steps:
  1. Create a class that inherits from Window, for example, MainWindow
2 . in Program.cs, instead of creating a Window, create a MainWindow (the new one)
Run and see what happens
Steven Kirk
@grokys
Feb 19 2015 18:05
ah... yeah
the styles aren't getting applied because it's no longer of class Window
hmm
that is indeed a problem that i'd not considered
i need to think about how to handle that
at the moment styles don't apply to derived types as that's not always what you want
José Manuel Nieto
@SuperJMN
Feb 19 2015 19:13
Oh, I now understand! You're discriminating based on exact type
José Manuel Nieto
@SuperJMN
Feb 19 2015 21:59
It would be great to allow derived classes :)
I'm a bit busy so I cannot take a look to it
:S
Steven Kirk
@grokys
Feb 19 2015 22:00
Yes it's definitely something we need. I need to think about the best way to do it though...
Richard Simpson
@RichiCoder1
Feb 19 2015 22:14
Is it not just adding Control.IsSubclassOf(StyleType)? Or is there more you want to do there?
Steven Kirk
@grokys
Feb 19 2015 22:16
yeah, something like that would work
though it shouldn't have to be explicit for subclasses of Window
Richard Simpson
@RichiCoder1
Feb 19 2015 22:17
What do you mean?
Steven Kirk
@grokys
Feb 19 2015 22:19
well if you subclass Window then it should automatically pick up the Window styles
maybe WPF's system where you override the style key explicitly when you want a new style would be the best
Richard Simpson
@RichiCoder1
Feb 19 2015 22:21
Indeed. I assume they went that direction for a reason
Steven Kirk
@grokys
Feb 19 2015 22:21
yeah, it always seemed strange that they did it like they did, but i think i'm starting to understand why now! ;)
the OfType<>() selector's name will have to change
any ideas?
Richard Simpson
@RichiCoder1
Feb 19 2015 22:29
Not of the top of my head. I'd need to look at the code
Steven Kirk
@grokys
Feb 19 2015 22:30
i think maybe StyledAs<>() could work
or maybe just leave it...
the
DefaultStyleKeyProperty.OverrideMetadata(typeof(TileGrid), new FrameworkPropertyMetadata(typeof(TileGrid)));
syntax always really annoyed me though for some reason
Richard Simpson
@RichiCoder1
Feb 19 2015 22:34
That is a bit verbos-y
Richard Simpson
@RichiCoder1
Feb 19 2015 22:42
I always forget how complicated styling gets:
http://www.interact-sw.co.uk/iangblog/2007/02/14/wpfdefaulttemplate
All kindsa black magic
Steven Kirk
@grokys
Feb 19 2015 22:43
yeah, i hoped to both simplify styles and make them more powerful by using a CSS-like system in perspex
who's knows if it'll turn out to work...
have you seen the styling code?
i need to do a blog post on it...
Richard Simpson
@RichiCoder1
Feb 19 2015 22:48

I was just thinking about that. WPF makes a lot assumptions because of the way it's designed to work with the underlying system. (CSS also was designed with the assumption that elements don't inherit until recently)

I haven't until recently. OfType<>() does seem a misnomer there. That's interestring how you do settings and selectors though. Seems very much a mix of CSS (selectors) and WPF (setters)

Steven Kirk
@grokys
Feb 19 2015 22:50
well, CSS has setters too
Richard Simpson
@RichiCoder1
Feb 19 2015 22:52
the new Setter(Property, Value) is a lot more reminicient of WPF here. Thought that may just be because I'm used to seeing
button {
    horizontalContentAlignment: center;
    verticalContentAlignment: center;
}
I think one big distiction between CSS and WPF is that a lot of CSS is written with the assumption of compound styles, while you only set one style for a XAML control. Get the whole XAML style BasedOn mess from that.
Steven Kirk
@grokys
Feb 19 2015 23:14
yeah, the BasedOn stuff is the main reason i wanted to try something else
but you can think of Setter(Property, Value) as just Property: Value
if/when we have a style markup it will be written like in CSS
José Manuel Nieto
@SuperJMN
Feb 19 2015 23:32
I see high-level talk here
niiiice!