These are chat archives for AvaloniaUI/Avalonia

18th
Feb 2015
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:14
Woohoo! merged from your master branch!
Untitled.png
And... TypeExtension is working!
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:26
at the moment, basic IUs can be designed with XAML
Steven Kirk
@grokys
Feb 18 2015 11:27
nice!
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:42
what's the next priority?
To have XAML automatically loaded in Windows?
like an InitializeComponent
Steven Kirk
@grokys
Feb 18 2015 11:43
yeah, i guess - or styles maybe
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:43
whoops, the styles thing is completely unknown for me
Steven Kirk
@grokys
Feb 18 2015 11:44
yeah, it's very different to WPF so completely new ground
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:44
do you think we could keep a list of styles
like a CSS
and apply them to a Window?
Steven Kirk
@grokys
Feb 18 2015 11:45
styles can be applied anywhere, not just to a window
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:45
OK
please, guide me with the automatic loading of XAML
Steven Kirk
@grokys
Feb 18 2015 11:45
i'm actually working on trying to write a markup parser myself currently
so we may be working in the same area soon
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:45
oh
Steven Kirk
@grokys
Feb 18 2015 11:45
automatic loading of XAML is really simple
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:46
the thing is that the Xaml Reader returns a VisualTree already
Steven Kirk
@grokys
Feb 18 2015 11:46
in WPF as you say, it just calls InitializeComponent
as usual, my advice would be to look how avalonia does it
it should be the same i think
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:47
yes, I know
but...
should that change?
in Perspex?
I thought of having some kind of Window Factory
Steven Kirk
@grokys
Feb 18 2015 11:48
what advantages would that bring?
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:49
the window factory could retrieve IWindows and do the wiring
avoiding the users to create instances of Windows on their own
Steven Kirk
@grokys
Feb 18 2015 11:49
hmm, not sure what you mean
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:50
doing var w = new Window() should be avoided
Steven Kirk
@grokys
Feb 18 2015 11:50
ok, why is that?
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:50
the construction of a Window with new breaks the whole DI principle
while a factory could be abstract
and retrieve an IWindow, initialized, wired with a VM and whatever
maybe even using an Uri
it's great for decoupling
IWindowFactory
windowFactory.Create("\MyWindow.xaml")
Steven Kirk
@grokys
Feb 18 2015 11:52
hmm, ok
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:52
it will retrieve an IWindow
Steven Kirk
@grokys
Feb 18 2015 11:52
but what does that buy you?
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:53
it decoupled the way a Window is created
Steven Kirk
@grokys
Feb 18 2015 11:53
other than "it's DI and DI is good"
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:53
haha
it offers a very good extensibility point
imagine that you want your Windows to be automatically attached, by naming convention, to a view model
you could do that almost with no work!
Steven Kirk
@grokys
Feb 18 2015 11:54
that
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:54
that's just an example
Steven Kirk
@grokys
Feb 18 2015 11:54
that's not actually something i've ever needed
why would you want that?
just trying to understand the use-case
i'm not a big fan of factories for factories sake
because everything starts getting a bit java
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:55
OK, you know: creating a Window actually involves parsing a XAML, or whatever markup
if the user can new up Windows
Steven Kirk
@grokys
Feb 18 2015 11:56
new Window()
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:56
yes, the bare metal factory could do that
but if the creation of a Window involves parsing stuff, doing some heavy work
Steven Kirk
@grokys
Feb 18 2015 11:56
do you have a solid use-case in mind? or is this just a "oh this might be useful"
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:57
no, no
the case use comes right now
Steven Kirk
@grokys
Feb 18 2015 11:57
ok, explain it ;)
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:57
xamlWindowFactory.Create(Uri)
right now, that is not possible
I would have to invoke a xamlReader (that is a way lower level) to get a Window
any parser will have the same problem
WPF solves that using InitializeComponent
Steven Kirk
@grokys
Feb 18 2015 11:58
yes, but why would you want to do that? every time i have wanted a window, i've known which window i wanted, so i could say new MainWindow() or new DialogWindow()
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:59
you won't be doing that if you use MVVM :)
Steven Kirk
@grokys
Feb 18 2015 11:59
and if they're not solid classes like MainWindow, DialogWindow you can't have code in them
José Manuel Nieto
@SuperJMN
Feb 18 2015 11:59
yes, you could!
a fully-fledged instance of your window would be retrieved
Steven Kirk
@grokys
Feb 18 2015 12:00
but MVVM doesn't handle creating new windows as creating new windows is a view-level concern
José Manuel Nieto
@SuperJMN
Feb 18 2015 12:00
MVVM uses services
Steven Kirk
@grokys
Feb 18 2015 12:01
ok, so you're talking about a service that can be called from the viewmodel layer to create a new window
José Manuel Nieto
@SuperJMN
Feb 18 2015 12:01
yes, that's it
Steven Kirk
@grokys
Feb 18 2015 12:01
ok, i understand now
José Manuel Nieto
@SuperJMN
Feb 18 2015 12:01
the VM should not be aware of any presentation logic
Steven Kirk
@grokys
Feb 18 2015 12:01
yes that is valid, but i'd say that the XAML layer is too low-level for that
José Manuel Nieto
@SuperJMN
Feb 18 2015 12:01
only the high level model that is going to be presented, but no UI logic
I think is a good idea to separate the concerns of build-logic from Window
I see it more like ASP.NET
and MVC
Steven Kirk
@grokys
Feb 18 2015 12:04
yes, i see where you're going
but like i say, i think the XAML lib is too low level for that
José Manuel Nieto
@SuperJMN
Feb 18 2015 12:04
but it doesn't have to do with XAML
but with Window creation
Steven Kirk
@grokys
Feb 18 2015 12:04
i think should be independent of the markup used
yes exactly
José Manuel Nieto
@SuperJMN
Feb 18 2015 12:04
a factory could do whatever to have the instance of your nice Window :)
no matter if it's loading from XAML
Steven Kirk
@grokys
Feb 18 2015 12:05
yes, so isn't this more at the level of an MVVM framework?
José Manuel Nieto
@SuperJMN
Feb 18 2015 12:05
I was talking about a specific implementation of the factory
no, just said the MVVM attaching behavior as an example
but that is possible if the factory is in charge of providing Windows
let's do one thing, I'll try
in my XAML branch
and see if it goes smooth
and gives good results
Steven Kirk
@grokys
Feb 18 2015 12:06
ok!
Richard Simpson
@RichiCoder1
Feb 18 2015 15:41
I'll point out that I do DI w/ WPF currently, just by registering Window (or MainWindow) with the DI container and getting an instance. Most DI containers already can emulate factories.