These are chat archives for AvaloniaUI/Avalonia

3rd
Nov 2017
danwalmsley
@danwalmsley
Nov 03 2017 10:55
@grokys to make that code compile when using avalonia from nugget package
you need to add serilog.sinks.trace package
to your app
Steven Kirk
@grokys
Nov 03 2017 10:57
yeah we need to improve that experience
danwalmsley
@danwalmsley
Nov 03 2017 11:04
@grokys if I get a message like this:
AvalonStudio Warning: 0 : Binding: Error in binding to "AvalonStudio.Controls.ViewModelViewHost"."DataContext": "Null value in expression '' at ''."
does this just mean there was nothing to bind to so it got null?
or is this some kind of error I need to fix?
Steven Kirk
@grokys
Nov 03 2017 11:08
that means that you have a binding like {Binding} (with no path) and DataContext was null
we need to make those warnings more readable!
that message format makes sense when you have a binding path but without one it's confusing
danwalmsley
@danwalmsley
Nov 03 2017 12:11
@grokys @jkoritzinsky this commit... seems to have broken lots of stuff for me
AvaloniaUI/Avalonia@0a6462d
now as looks like this
image.png
the main points to note are
styles are not getting applied to, toobar button background, document tab buttons, and font size on the tool dock controls (bottom with blue text, size is now larger than can fit)
Steven Kirk
@grokys
Nov 03 2017 12:13
oh, that's not good. that commit shouldn't have changed behavior, only api
danwalmsley
@danwalmsley
Nov 03 2017 12:15
I went 1 commit behind and it works
then that commit and it broke
Steven Kirk
@grokys
Nov 03 2017 12:15
damn it...
danwalmsley
@danwalmsley
Nov 03 2017 12:16
it looks like its some setters not getting called
Steven Kirk
@grokys
Nov 03 2017 12:16
i bet it's a one-liner somewhere
danwalmsley
@danwalmsley
Nov 03 2017 12:16
if the values are changed by styles like pointer over
it then corrects the values
not sure where to look to track it down
Steven Kirk
@grokys
Nov 03 2017 12:17
hmm yeah not sure either...
can take a look shortly
danwalmsley
@danwalmsley
Nov 03 2017 12:18
it looks to me like its only when something is decalred only in a style
i'll check if a simple repro can be done on control catalog
woohoo first time a simple repro worked for me
Steven Kirk
@grokys
Nov 03 2017 12:22
oh great!
danwalmsley
@danwalmsley
Nov 03 2017 12:22
AvaloniaUI/Avalonia@1e0a4e9
if I go to before that commit I get this
image.png
if I go after
none of the buttons go red
Steven Kirk
@grokys
Nov 03 2017 12:23
did you just add a style for the buttons?
danwalmsley
@danwalmsley
Nov 03 2017 12:23
basically
like that
added styles to the stackpanel that contains them
I'm also having a wired issue with DockPanel.Dock property, but I will do an issue and repro first
Steven Kirk
@grokys
Nov 03 2017 12:25
ok cool - will fix that shortly
danwalmsley
@danwalmsley
Nov 03 2017 12:25
I this this dockpanel thing is something that may have been there a while
@grokys would you expect this observable to get called
    public class DocumentTabItem : ContentControl
    {
        static DocumentTabItem()
        {
            PseudoClass(IsFocusedProperty, o => o, ":focused");
            PseudoClass(DockPanel.DockProperty, o => o == Dock.Right, ":dockright");
            PseudoClass(DockPanel.DockProperty, o => o == Dock.Left, ":dockleft");
            PseudoClass(DockPanel.DockProperty, o => o == Dock.Top, ":docktop");
            PseudoClass(DockPanel.DockProperty, o => o == Dock.Bottom, ":dockbottom");
        }

        public DocumentTabItem()
        {
            this.GetObservable(DockPanel.DockProperty).Subscribe(dock =>
            {
                var parent = Parent;
            });
        }
or would I need to make my control an Owner of DockProperty?
Steven Kirk
@grokys
Nov 03 2017 12:28
hmm no, that should work i think
is the DockPanel.Dock property actually being set?
danwalmsley
@danwalmsley
Nov 03 2017 12:28
hmm ok I'll try and do a repro, basically what I see is the pseudo class gets applied
but I don't see any layout change
until I force a resize of the parent control (TabStrip)
and this observable never gets called
Steven Kirk
@grokys
Nov 03 2017 12:29
hmm ok, sounds like a bug
danwalmsley
@danwalmsley
Nov 03 2017 12:30
hmm but it might be tabcontrol wierdness
AlessandroMiorelli
@AlessandroMiorelli
Nov 03 2017 13:19
Hi,
currently I have a project wrote in WPF, XAML and c#.
In this application I have a canvas with some controls (rectangles, text...)
This application works with blackmagic decklink video card.
Decklink function provides an IntPtr where my application writes the byte array of frame buffer.
WPF don't give me the frame buffer, so I need to use rendertargetbitmap to have snapshot of this canvas and after that I use CopyPixel to copies the bitmap pixel data in this IntPtr
I use rendertargetbitmap because I need alpha channel. If I use BitBlt or something like that I can't have alpha channel.
I have same problem if I try to extract the output data from video card.
Can avalonia provide me the framebuffer?
Nikita Tsukanov
@kekekeks
Nov 03 2017 13:59
Then ask use Skia backend and to create a render target for it by passing IFramebufferPlatformSurface implementation to AvaloniaLocator.Current.GetService<IPlatformRenderInterface>().CreateRenderTarget(...)
@danwalmsley awesome
hacklex
@hacklex
Nov 03 2017 14:46
Checked out the look of the studio, thought maybe the toolbar can be improved a bit
blob
Compare how the first 5 buttons appear next to the current versions
AlessandroMiorelli
@AlessandroMiorelli
Nov 03 2017 14:48
Thank you Nikita. I'm a newbie in avalonia. If it is not so hard for you, please could you provide me a simple example with a transparent canvas with inside a button. Pressing this button the application should create the frame buffer of the canvas
Gutemberg Ribeiro
@galvesribeiro
Nov 03 2017 15:03
@danwalmsley congrats!
danwalmsley
@danwalmsley
Nov 03 2017 15:21
@hacklex there is a recent bug in avalonia causing this
@galvesribeiro thanks
@hacklex still a lot of ui improvements to be made! still looking for people to help out with this kind of stuff ;)
@kekekeks @grokys I think we need some way that XAML style files can load themselves, at the moment I have to add a line to app.xaml if I add a new control
if the control comes from a plugin, it kind of breaks the ability to distribute the plugin separately from the main ide
Steven Kirk
@grokys
Nov 03 2017 15:25
yeah, definitely something we need
danwalmsley
@danwalmsley
Nov 03 2017 15:26
I saw @jkoritzinsky did an auto loading styles thing
but it never seemed to get merged
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 15:28
It wasn't merged because it doesn't work on IOS unless you add an init method so you have an explicit reference. It would be nice though since it would work on all non-iOS platforms
hacklex
@hacklex
Nov 03 2017 15:56

@danwalmsley

@hacklex still a lot of ui improvements to be made! still looking for people to help out with this kind of stuff ;)

Ok, will wait until the bug is fixed then, and see if there's something I can quickly do about it.

danwalmsley
@danwalmsley
Nov 03 2017 15:59
yeah, I'm hoping to have a release where you can create and edit, build, debug avalonia apps in a few weeks
once that's ready it will in a better place for people to start submitting fixes and improvements
if you have any ideas for icons Id be interested
danwalmsley
@danwalmsley
Nov 03 2017 16:13
I could be wrong, but I think something is seriously broken with bindings
if I have a viewmodel
and 2 controls
i.e.
vm -> myProperty
   ControlA -> MyProperty
   ControlB -> MyProperty
and the view is like

```

<Grid>
<ControlA MyProperty={Binding myProperty />
<ControlB MyProperty={Binding myProperty />
</Grid>

only control B seems to be initialised with the property from the vm
and controlA gets null
also control A doesn't get notified of further changes
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 16:43
That sounds like one of the bugs behind #855. Can you try with #856 and let me know if that fixes it?
danwalmsley
@danwalmsley
Nov 03 2017 16:46
@jkoritzinsky I think I found it
<previewer:AvaloniaPreviewer Xaml="{Binding SourceText} SourceFile={Binding SourceFile}" />

<previewer:AvaloniaPreviewer Xaml="{Binding SourceText}" SourceFile={Binding SourceFile}" />
spot the difference
missing " didn't crash portable.xaml
Curtis Wensley
@cwensley
Nov 03 2017 16:47
oh yay!
danwalmsley
@danwalmsley
Nov 03 2017 16:47
@cwensley hey, hows portable.xaml going?
I'm finding a lot of the exceptions would be really useful if they reported the File, Line and Column
like right now I have this...
Curtis Wensley
@cwensley
Nov 03 2017 16:48
hm, i think you can turn that on in the reader options.. though it might not be fully baked
danwalmsley
@danwalmsley
Nov 03 2017 16:48
image.png
but I have no idea which XAML file its for
shall I create an issue?
Curtis Wensley
@cwensley
Nov 03 2017 16:49
hm, that sounds like an avalonia issue if you want to know what file it is
portable.xaml probably just gets a stream at that point
danwalmsley
@danwalmsley
Nov 03 2017 16:49
ah I see
so avalonia should catch it
Curtis Wensley
@cwensley
Nov 03 2017 16:50
aye
danwalmsley
@danwalmsley
Nov 03 2017 16:50
and then report to me the file, line, column and error message
ok that sounds easy to fix
shall I send you an issue for the XAML where it should have thrown an exception?
Curtis Wensley
@cwensley
Nov 03 2017 16:57
@danwalmsley: yes, that would be very helpful!
rconde01
@rconde01
Nov 03 2017 18:22
hey mr Eto
Curtis Wensley
@cwensley
Nov 03 2017 18:23
hi (;
rconde01
@rconde01
Nov 03 2017 18:23
whats your interest in Avalonia?
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 18:57
He's the maintainer of the XAML engine we're using
Curtis Wensley
@cwensley
Nov 03 2017 18:57
^
(;
Curtis Wensley
@cwensley
Nov 03 2017 19:03
Plus I made the changes to MonoMac that you guys are using for your MonoMac/.NET Core stuff.
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:05
Yeah that too :)
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:05
Yeah, 64-bit compatibility changes, much appreciated
@rconde01 Avalonia is more "general-purpose", eto is more "native"
I think our binding system is better though
Curtis Wensley
@cwensley
Nov 03 2017 19:09
lol ;b
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:09
Tbh I think our binding system is the best one for a XAML-based toolkit I've seen. I'm also a little biased haha.
Curtis Wensley
@cwensley
Nov 03 2017 19:09
I honestly know nothing of Avalonia's binding system. Don't you guys use reactive extensions?
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:10
We use RX under the hood.
We tried to replicate the design of WPFs binding system.
Last I checked, Eto looked more like WinForms' style binding system IIRC
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:10
eto's binding system is very basic, IMO
Curtis Wensley
@cwensley
Nov 03 2017 19:11
I honestly hate WPF's binding system. Very loose, and impossible to extend.
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:11
Ours is more extensible than WPF's
Curtis Wensley
@cwensley
Nov 03 2017 19:13
@kekekeks probably true compared to RX, but you can also do all binding in code instead of relying on XAML to make the syntax easier
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:14
Ehm...
Curtis Wensley
@cwensley
Nov 03 2017 19:14
e.g. textBox.BindDataContext(c => c.Text, (MyViewModel m) => m.Some.Properties.That.Return.The.Value);
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:14
Ours can also be done in code. It was kind of a necessity since we didn't use a XAML engine in the start
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:15
Let me find an example of our syntax for binding from code
Curtis Wensley
@cwensley
Nov 03 2017 19:15
but again, I don't know anything about Avalonia so maybe you have a better way than WPF.
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:16
textbox[!TextBox.TextProperty] = new Binding("Some.Properties.That.Return.The.Value") {Source = m}) for a one-way binding
milkinllc
@milkinllc
Nov 03 2017 19:16
reactiveui plays very well in this case IMO
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:17
Or textbox[!TextBox.TextProperty] = new ExpressionObserver(m, "Some.Properties.That.Return.The.Value")).ToBinding() IIRC. This one's more from memory.
For a two-way binding, use two !! and change ExpressionObserver to BindingExpression
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:17
I think we can also directly bind to observable
Curtis Wensley
@cwensley
Nov 03 2017 19:18
hm, using magic strings tho, but maybe you have a way to do otherwise
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:18
textbox[!TextBox.TextProperty] = someobservable
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:18
It's true we don't have a way to use strong typing, but we could use Expression Trees to parse out the path from something strongly typed.
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:18
we also have a proper binding priority system
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:18
We just haven't needed that yet
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:19
Yeah, it should be possible to parse expression trees
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:20
We just haven't needed to do that yet
Curtis Wensley
@cwensley
Nov 03 2017 19:20
@kekekeks nice, yeah no priority in Eto, just in order that the bindings were set up.
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:21
It would be nice to have a common library for stuff like DependencyObject, DependencyProperty and bindings
Curtis Wensley
@cwensley
Nov 03 2017 19:22
I agree
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:22
It'd be awesome to have that, but it's not going to happen for a long time. Especially with Microsoft projects. For the rest of us though, we could pull that off.
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:22
That would also allow seamless integration between frameworks
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:23
With some refactoring, we could totally separate out almost all of our binding infrastructure from the rest of Avalonia.
RelativeSource/ElementName/TemplatedParent bindings are really the only ones that need to touch our control library
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:25
That could be abstracted out of the implementation
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:26
I agree
As of now, the only reason the Avalonia.Markup assembly depends on Avalonia.Controls is because of ControlLocator
There's a few more dependencies in the Avalonia.Markup.Xaml.Binding class that depend on specific AvaloniaPropertys on controls (like TemplatedParent), but nothing we couldn't abstract out with some sort of configuration class.
rconde01
@rconde01
Nov 03 2017 19:32
It would be nice to have an avalonia host inside of eto, in the case where you mostly want to use avalonia but you need to mix with native components
of course avalonia could do that itself, but since Eto is already there...
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:34
@kekekeks could probably put something together for that at some point. He's a master when it comes to Avalonia interop with other UI frameworks
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:35
Well, the main problem would be the embedding into the native UI toolkit
That eto is using on particular platform
It's failrly easy to support integration with eto running on top of WPF/Xamarin.Android/Xamarin.iOS
Since we already have view hosts for these platforms
Our mobile platform backends are actually designed to be hosted inside native views
Because there is no "native" window access anyway
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:36
Xamarin.Mac should be pretty easy as long as we multi-target for Xamarin.Mac with our MonoMac backend (which we don't do currently, but we totally could)
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:36
The problem about Xamarin.Mac
Is that our current MonoMac backend won't work well without its own NSWindow
It expects a particular setup
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:37
We can build our own NSWindow in a Xamarin.Mac build. That's what I got when I was prototyping an AppKit backend IIRC
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:37
The problem with GTK is, well, GTK being GTK
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:38
All of the windowing features I implemented worked correctly
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:38
@jkoritzinsky yeah, but for embedding into eto we need to be hosted inside an NSView
Without any control over the window
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:38
Good point.
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:39
It should be possible to do
But I haven't designed the backend to work that way yet
Another problem is layout system integration
The only framework with a proper layout system is WPF
GTK has something that remotely resembles WPF (at least it has a concept of Size Request and two-stage layout, so we can work with that)
Cocoa...
Well, in terms of layout it's stuck in 1990-s
Even winforms have a better layout system
I'm not sure how eto works with that
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:42
Isn't AppKit's layout system similar to UIKit's?
i.e. couldn't we use similar designs as what we did for iOS embedding into a UIView (in terms of layout) on Xamarin.Mac/MonoMac for embedding into an NSView?
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:46
We don't have layout integration for UIView embedding
It essentially works like a webview
That will occupy the space provided for the view
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:47
Oh. Ok. I understand
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:47
Another problem is that our Measure method has side-effects
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:47
Right... Didn't we start a conversation like a year/year and a half ago about maybe changing that?
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:48
And those side-effects will break things on the next layout pass
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:48
So that we won't have to worry about layout passes getting borked?
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:48
The problem is that we need it to have side effects for performance reasons
So it will cache the previous measure
And won't recalculate it if nothing is changed
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:50
Good point. Could we have a non-side effect version for speculatively measuring a control that just returns the value instead of caching it? Or would that not be worth the extra code to implement?
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:50
That will require changes in each of the containers
grid, stacklayout, etc
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 19:52
Yeah that's what I was afraid of.
Though it looks like only a small number of our layout controls actually cache results from their MeasureOverride implementations
Looks like only Layoutable and Grid cache results as far as I can tell from a quick lookover.
Nikita Tsukanov
@kekekeks
Nov 03 2017 19:58
Well, most containers use DesiredSize of child controls, I think
It's probably better to ask @grokys
Jeremy Koritzinsky
@jkoritzinsky
Nov 03 2017 20:00
Good idea
Big Jake
@jakesays
Nov 03 2017 22:51
so how far has avalonia diverged from wpf?
Nikita Tsukanov
@kekekeks
Nov 03 2017 22:53
Stylng system is different
It uses css-like selectors