These are chat archives for AvaloniaUI/Avalonia

24th
Jan 2019
drearyrainDeng
@drearyrainDeng
Jan 24 00:14
@donandren thanks ,it is work
Matthew Leibowitz
@mattleibow
Jan 24 00:43
@kekekeks Just having a look at that ubuntu16 issue you mentioned on teams - I am thinking of switching to clang as that will (supposedly) massively boost the library speed
Matthew Leibowitz
@mattleibow
Jan 24 00:49
Do you think that will help? I'll test on Debian, but just wanted to get some Linux expertise here. I am going to try build on Ubuntu16 + Clang 3.8 as that is what comes with it.
James Burnside
@JCBurnside
Jan 24 04:15
Nikita Tsukanov
@kekekeks
Jan 24 07:52
@mattleibow Using clang might be a good idea, but we need some actual benchmarks to test it
BTW, you still need to use some old distro (like Ubuntu 14.04) to produce a portable binary
Nikita Tsukanov
@kekekeks
Jan 24 07:58
It should be possible to use a modern distro with ubuntu 14.04 root fs for cross-compilation
But Ubuntu 14.04 image from Azure works fine after applying https://gist.github.com/heartonbit/2575ce02ca730559d2f2c65eb8682231 and using extra_ldflags=["-static-libstdc++", "-static-libgcc"]
Setting up a rootfs-based cross-compilation would allow us to build for ARM systems
Naeron1984
@Naeron1984
Jan 24 10:44
Hi guys, do you know of any example project where Avalonia is used with ReactiveUI. I have a hard time using it. I followed the example on ReactiveUI's page and basically the WhenActivated even doesn't get called.
just this getting started nothing fancy: https://reactiveui.net/docs/getting-started/
Steven Kirk
@grokys
Jan 24 10:47
hmm @Naeron1984 WhenActivated should have gone into the 0.8 release: AvaloniaUI/Avalonia#1852
i started working on an MVVM tutorial for Avalonia with ReactiveUI here AvaloniaUI/avaloniaui.net#38
it's not finished yet, but it might help?
Naeron1984
@Naeron1984
Jan 24 10:54
Yes I have, the MVVM template generated that call for me. Also using the latest source code not NuGet packages.
Steven Kirk
@grokys
Jan 24 10:56
ok let me give it a try
Naeron1984
@Naeron1984
Jan 24 10:56
thanks

also possible bug: ReactiveUserControl

public class ReactiveUserControl<TViewModel> : UserControl, IViewFor<TViewModel> where TViewModel : class
    {
        public static readonly AvaloniaProperty<TViewModel> ViewModelProperty = AvaloniaProperty
            .Register<ReactiveWindow<TViewModel>, TViewModel>(nameof(ViewModel));

Possibly, property should be registered for ReactiveUserControl insted of ReactiveWindow

Steven Kirk
@grokys
Jan 24 11:01
@Naeron1984 just tried it here using:
    public class BorderPage : ReactiveUserControl<object>
    {
        public BorderPage()
        {
            this.InitializeComponent();
            this.WhenActivated(x =>
            {
            });
        }

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }
    }
and the WhenActivated lambda gets called
@Naeron1984 yes good catch!
actually it should probably be using AddOwner
but that shouldn't be what's causing your problem
could you post the view that WhenActivated isn't being called on?
Steven Kirk
@grokys
Jan 24 11:28
@ahopper AvaloniaUI/Avalonia#2264 should fix #1099
ahopper
@ahopper
Jan 24 11:31
great, I'll try it over lunch, got to earn my lunch first though
Steven Kirk
@grokys
Jan 24 11:32
haha sure
Naeron1984
@Naeron1984
Jan 24 11:35

@grokys

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);

The Load call prevents it from being called for an unknown reason to me

I just commented everything out and surpriseingly it this is the problem but obviously this cannot be left out
BTW I just use an emty main window
Nikita Tsukanov
@kekekeks
Jan 24 11:37
I think activation support is done via some hacks
Basically it subscribes to Initialized and Closed events
Naeron1984
@Naeron1984
Jan 24 11:39
An why does AvaloniaXamlLoader.Load(this); prevent it from being called?
Ok, so i moved AvaloniaXamlLoader.Load(this); into WhenActived callback and it works
Nikita Tsukanov
@kekekeks
Jan 24 11:53
Wait, what
@grokys it seems that IAttachedToVisualTree event is broken when there is InitializeComponent call
Artyom
@worldbeater
Jan 24 11:58
https://reactiveui.net/docs/handbook/data-binding/avalonia
AvaloniaXamlLoader.Load(this); is a heavy operation, and AttachedToVisualTree event (or Initialized event, if you use a Window) is called before it completes. So that's why you need to call WhenActivated before AvaloniaXamlLoader.Load(this). BTW worth referencing those docs from Avalonia side also, that page seems to be hard to find now x)
Naeron1984
@Naeron1984
Jan 24 12:01
This is the only way(for now) I managed to make it work:
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using DeppUIVector.ViewModels;
using ReactiveUI;
using System.Reactive.Disposables;

namespace DeppUIVector.Views
{
    public class MainWindow : ReactiveWindow<MainWindowViewModel>
    {
        public TextBlock Tb1 { get { return this.FindControl<TextBlock>("tbTest"); } }


        public MainWindow()
        {
            //InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            var disposable = this.WhenActivated(disposableRegistration =>
            {
                AvaloniaXamlLoader.Load(this);
                this.Bind(ViewModel,
                              viewModel => viewModel.Greeting,
                              view => view.Tb1.Text)
                              .DisposeWith(disposableRegistration);
            });
        }

        private void InitializeComponent()
        {


            ////This only works properly from here
            //var graphEditorWindow = new GraphEditorWindow();
            //graphEditorWindow.Show();

            //Closing += MainWindow_Closing;
        }

        private void MainWindow_Closing(object sender, System.EventArgs e)
        {
            //Application.Current.Exit();
        }
    }
}
Replacing view.Tb1.Text with FindControl throws an exception. I suspect because the lambda expression gets compiled into some other code and not directly used.
This: System.NotSupportedException: 'Index expressions are only supported with constants.'
And I don't even use WhenActived in the View Model
Naeron1984
@Naeron1984
Jan 24 12:09
@worldbeater Please note my previous comments about FindControl
Artyom
@worldbeater
Jan 24 12:13
image.png
image.png
We definitely need to document that FindControl won't work if it is used inside an expression. Thank you for reporting this @Naeron1984! <3
Artyom
@worldbeater
Jan 24 12:26
Opened an issue, gonna fix that soon reactiveui/website#276
Artyom
@worldbeater
Jan 24 12:36
Opened a PR that fixes wrong AvaloniaProperty type for ReactiveUserControl AvaloniaUI/Avalonia#2265
ReIaxo
@ReIaxo
Jan 24 12:54

Hello, I have a problem with running a simple Hello World example on my Raspberry pi with Raspbian Strech. I published the Example with dotnet publish -r linux-arm --framework netcoreapp2.0. If i do dotnet HelloAvalonia.dllon the Rapsberry Pi, i get the following exception:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Avalonia.Skia.TypefaceCache' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libSkiaSharp': The specified module or one of its dependencies could not be found.
 (Exception from HRESULT: 0x8007007E)
   at SkiaSharp.SkiaApi.sk_typeface_create_from_name(String str, SKTypefaceStyle style)
   at Avalonia.Skia.TypefaceCache.CreateDefaultTypeface()
   at Avalonia.Skia.TypefaceCache..cctor()
   --- End of inner exception stack trace ---
   at Avalonia.Skia.FormattedTextImpl..ctor(String text, Typeface typeface, TextAlignment textAlignment, TextWrapping wrapping, Size constraint, IReadOnlyList`1 spans)
   at Avalonia.Skia.PlatformRenderInterface.CreateFormattedText(String text, Typeface typeface, TextAlignment textAlignment, TextWrapping wrapping, Size constraint, IReadOnlyList`1 spans)
   at Avalonia.Controls.TextBlock.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Controls.StackPanel.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding)
   at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding)
   at Avalonia.Controls.Primitives.AdornerDecorator.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding)
   at Avalonia.Controls.Border.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize)
   at Avalonia.Controls.Window.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutManager.Measure(ILayoutable control)
   at Avalonia.Layout.LayoutManager.ExecuteInitialLayoutPass(ILayoutRoot root)
   at Avalonia.Controls.Window.Show()
   at Avalonia.Application.Run(Window mainWindow)
   at Avalonia.Controls.AppBuilderBase`1.Start[TMainWindow](Func`1 dataContextProvider)
   at HelloAvalonia.Program.Main(String[] args) in H:\Kram\Studium\Osnabrück\S7\Projektbericht\Beipielapplikationen\HelloAvalonia\HelloAvalonia\Program.cs:line 13
Abgebrochen

So the libSkiaSharp.so is missing in the publish directory.

Steven Kirk
@grokys
Jan 24 13:17
@worldbeater what would be needed to make WhenActivated work in a Window after the call to InitializeComponent?
how does it work in WPF?
Artyom
@worldbeater
Jan 24 13:30
@grokys afair, in WPF the Loaded event is called after a call to InitializeComponent() returns. This is how ActivationForViewFetcher is implemented for uwp and wpf: https://github.com/reactiveui/ReactiveUI/blob/781cea984f79d42d3ae3e3fb3133f4882338d7c0/src/ReactiveUI/Platforms/windows-common/ActivationForViewFetcher.cs#L49 So feels like we need a Loaded event with behavior similar to WPFish
Steven Kirk
@grokys
Jan 24 13:34
ok, i'll take a look into that, thanks!
danwalmsley
@danwalmsley
Jan 24 13:42
@ReIaxo you need an arm version of libskiasharp
You will need to compile yourself, check skiasharp repo, they may have one now
Nikita Tsukanov
@kekekeks
Jan 24 14:04
ARM RIDs are confusing
linux-arm is armhf
tizen-arm is armel
wtf
Matthew Leibowitz
@mattleibow
Jan 24 14:05
hehe
We don't yet have a rasbian / arm release
This issue may help: mono/SkiaSharp#453
Nikita Tsukanov
@kekekeks
Jan 24 14:13
I'm going to add armhf binary to Avalonia.Skia.Natives.Linux
Matthew Leibowitz
@mattleibow
Jan 24 14:13
nice!
Try using clang - I think I am going to switch to that
I have noticed a 2MB reduction is size for x64
Nikita Tsukanov
@kekekeks
Jan 24 14:14
It will target glibc 2.23 since I don't want to bother with building a fresh cross-compiler for 14.04
Matthew Leibowitz
@mattleibow
Jan 24 14:17
clang 3.8 comes with ubuntu 14
ah, for arm...
Nikita Tsukanov
@kekekeks
Jan 24 14:19
Not sure if Skia can be built using clang 3.8
GCC 4.9 that comes with 14.04 can't built it
Matthew Leibowitz
@mattleibow
Jan 24 14:22
checking right now
200 files in
checked on 16.04, and that went fine
Google says that clang is their preferred, recommended and tested compiler
gcc is just hanging around and "works"
I believe the new min for clang is 3.7 or c++ 14
oops, my bad clang 3.4
gcc 5 and clang 3.4
Nikita Tsukanov
@kekekeks
Jan 24 14:25
$ file out/linux/armhf/libSkiaSharp.so.68.1.0 
out/linux/armhf/libSkiaSharp.so.68.1.0: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=7eadd69a314b3dbd9bc23c8eae809d936acc2d46, stripped


$ readelf -d out/linux/armhf/libSkiaSharp.so.68.1.0 

Dynamic section at offset 0x5dfef0 contains 30 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libfontconfig.so.1]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]
 0x0000000e (SONAME)                     Library soname: [libSkiaSharp.so.68.1.0]
Mkay, seems legit
Will try with 14.04 chroot and clang later
The problem is that I have to use a separate chroot for armhf
since libfontconfig1-dev:armhf can't be installed alongside with libfontconfig1-dev:amd64
Same goes for other libraries
Matthew Leibowitz
@mattleibow
Jan 24 14:27
ah, yeah
Nikita Tsukanov
@kekekeks
Jan 24 14:28
14.04 seems to have a separate package with clang 3.9
Will try
Nikita Tsukanov
@kekekeks
Jan 24 14:34
Mkay, ubuntu doesn't have armel port
noice
Nope, can't install clang alongside with armhf dev packages
Nikita Tsukanov
@kekekeks
Jan 24 14:41
Mkay, it's possible to do it via custom-built clang or manually changing dpkg database
But for now I won't bother and package the gcc-built binary for glibc 2.23+
Actually, GLIBC_2.17+
according to objdump -T out/linux/armhf/libSkiaSharp.so.68.1.0 |egrep -o 'GLIBC_2.[0-9]+'|sort -n|uniq
Try this package once it gets indexed
Should work fine with Ubuntu 16.04+ (or any distro with glibc 2.17+
Nikita Tsukanov
@kekekeks
Jan 24 15:08
@mattleibow
Actually it seems that clang can use a different chroot environment via sysroot option
So it should be possible to compile for 14.04 from 18.04
ReIaxo
@ReIaxo
Jan 24 15:12
Ok, thanks for your answers. I will take a look at all the suggestions and tell you, which works for me.
@kekekeks ok. then have to use ubuntu 16.04+ instead of raspbian stretch, right?
2.24
Should be compatible
ahopper
@ahopper
Jan 24 15:19
@grokys #2264 appears to have reduced my binding errors but I still seem to have a problem, it appears when the ContentControl Content changes (via binding) the new template is initially bound with a null datacontext. The day job is a bit hectic but will try and create a repro soon.
Nikita Tsukanov
@kekekeks
Jan 24 15:21
@mattleibow
You can generate sysroot using
qemu-debootstrap --arch=armhf --include=libfontconfig1-dev jessie /opt/debian-armhf
And then somewhat follow this guide
that would require apt-get install binfmt-support qemu qemu-user-static debootstrap and clang version of your choice
Matthew Leibowitz
@mattleibow
Jan 24 15:26
So I git it built o Ubuntu 14 with clang 3.8:
GLIBC_2.14
GLIBC_2.2
GLIBC_2.3
GLIBC_2.7
Nikita Tsukanov
@kekekeks
Jan 24 15:27
:+1:
check for deps via readelf -d
(look for (NEEDED) entries)
libpthread libdl libfontconfig libm libc and ld-linux-whatever are fine
Matthew Leibowitz
@mattleibow
Jan 24 15:30
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libfontconfig.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
Nikita Tsukanov
@kekekeks
Jan 24 15:31
add -static-libstdc++ to c flags
Matthew Leibowitz
@mattleibow
Jan 24 15:36
and the libgcc_s? Is that fine?
or does the static flag link that in to?
Nikita Tsukanov
@kekekeks
Jan 24 15:37
-static-libgcc
There were breaking changes in libstdc++ in the past
And it's a part of GCC
so I won't trust libgcc either
Matthew Leibowitz
@mattleibow
Jan 24 15:40
how does this affect the fact that we load GL via dlopen?
Nikita Tsukanov
@kekekeks
Jan 24 15:40
Doesn't affect
dlopen is from libc
malloc/free are from libc
As long as we don't consume any libraries with C++ exports we are fine
Matthew Leibowitz
@mattleibow
Jan 24 15:41
ah. I think I am getting the hang of this.
Nikita Tsukanov
@kekekeks
Jan 24 15:43
glibc had perfect backwards compatibility so far
via symbol versioning
Matthew Leibowitz
@mattleibow
Jan 24 15:45
Shared library: [libpthread.so.0]
Shared library: [libdl.so.2]
Shared library: [libfontconfig.so.1]
Shared library: [libm.so.6]
Shared library: [libc.so.6]
Shared library: [ld-linux-x86-64.so.2]
Nikita Tsukanov
@kekekeks
Jan 24 15:45
:+1:
There seems to be a way to target older glibc via http://ftp.ntu.edu.tw/software/libs/glibc/hjl/compat/
But I haven't checked if it works
Matthew Leibowitz
@mattleibow
Jan 24 15:46
but ubuntu 14 seems to be ok so far
that little boy still hanging onto the world :) It is like the XP for Linux ;)
Nikita Tsukanov
@kekekeks
Jan 24 15:48
Tell that to RHEL 6
Released at 2010, supported till 2024
Actually, RHEL 5 seems to still be supported
But we can't target them anyway
Because of way too old version of libfontconfig
But Mono still has support for RHEL6
Matthew Leibowitz
@mattleibow
Jan 24 15:50
that lib is still blowing up on Debian 9
Nikita Tsukanov
@kekekeks
Jan 24 15:50
In which way?
Matthew Leibowitz
@mattleibow
Jan 24 15:51
can't load libSkiaSharp
Nikita Tsukanov
@kekekeks
Jan 24 15:52
/lib/ld-linux.so.2 --list libSkiaSharp.so
The most likely culpit is libfontconfig1 package not being installed
It isn't included in net core docker image
Matthew Leibowitz
@mattleibow
Jan 24 15:58
well, that is embarrassing... that is what I tell everyone when it fails to load :)
seems all my other machines I did it, but skipped this one
I am actually using the WSL :) Great for testing all sorts of things before using VMs/Docker
Matthew Leibowitz
@mattleibow
Jan 24 16:04
I also set skia_use_system_freetype2 to false. This is going to use the freetype that comes with skia
Should I revert that, or is that something we want?
Nikita Tsukanov
@kekekeks
Jan 24 16:05
Skia uses a fresh version of libfreetype
While system one might be a bit old
And not support font files shipped with the application properly, for example
Matthew Leibowitz
@mattleibow
Jan 24 16:07
nice!
Nikita Tsukanov
@kekekeks
Jan 24 16:07
This is the commit that's currently referenced by skia
Matthew Leibowitz
@mattleibow
Jan 24 16:08
I have this issue: mono/SkiaSharp#718
It has all the dependencies of skia (some used, some not)
If you need an update to any of the dependencies - just let me know and I can see about getting it in
Nikita Tsukanov
@kekekeks
Jan 24 16:09
Good
Now we have some commit between 2.9 and 2.9.1
Ubuntu 18.10 ships with 2.8.1
Ubuntu 16.04 ships with 2.6.1
Benedikt Stebner
@Gillibald
Jan 24 16:25
I have just finished updateing all XCode projects. Hopefully with success :)
Nikita Tsukanov
@kekekeks
Jan 24 16:33
Updating to what?
Ah, harfbuzz
Matthew Leibowitz
@mattleibow
Jan 24 16:44
the machines will inform us of our successes and failures.
Benedikt Stebner
@Gillibald
Jan 24 16:45
👍
James Burnside
@JCBurnside
Jan 24 16:46
with grid Column/Row definitions does X* mean like X percent or what? (I was confused with what it meant with wpf as well)
Matthew Leibowitz
@mattleibow
Jan 24 16:51
@Gillibald the machines just blew up - the xcode projects... DO you have a mac/xcode?
If not, I can get that in
James Burnside
@JCBurnside
Jan 24 16:54
also with binding modes is OneWayToSource oneway to viewmodel or from?
Nikita Tsukanov
@kekekeks
Jan 24 16:57
To
OneWay is from
1*,3*,2* means 20%, 60%, 40%
Benedikt Stebner
@Gillibald
Jan 24 16:59
@mattleibow I do not have a Mac thats why I have to edit everything by hand and make sure that I produce valid projects. It would Speed up things if you do that for me. All other platforms build sucessfully.
Matthew Leibowitz
@mattleibow_twitter
Jan 24 17:03
Sure, I will get on that.
James Burnside
@JCBurnside
Jan 24 17:03
hmmm.... well it seems either I am doing something wrong with my bindings or OneWayToSource isn't working on canvas inside a dockpanel
Nikita Tsukanov
@kekekeks
Jan 24 17:06
one way to source takes values from controls and writes them to the view model
James Burnside
@JCBurnside
Jan 24 17:07
yes. I need the height and width of the canvas to do some calculations in my VM
Nikita Tsukanov
@kekekeks
Jan 24 17:07
You need to bind to Bounds then
Same as in WPF with ActualWidth/ActualHeight instead of Width/Height
James Burnside
@JCBurnside
Jan 24 17:10
Is there an example of binding to bounds?
Nikita Tsukanov
@kekekeks
Jan 24 17:11
Should work like every other binding
James Burnside
@JCBurnside
Jan 24 17:11
but what is the type?
Nikita Tsukanov
@kekekeks
Jan 24 17:12
Rect
stropheum
@stropheum
Jan 24 17:57
Hey guys, I have a question. What do you think the most reasonable way is to package a mac app bundle to run an avalonia app? I have a client that for some reason is really intimidated by ./
i was thinking of just writing a cocoa app that i can drop into the publish folder that just runs the dll like a script and hides the console window
Steven Kirk
@grokys
Jan 24 18:23
@worldbeater @Naeron1984 does AvaloniaUI/Avalonia#2266 look like a decent solution to the .WhenActivated problem?
Nikita Tsukanov
@kekekeks
Jan 24 18:43
Will only work for toplevel views
If view is inside tabitem
It won't fire activated event properly
Steven Kirk
@grokys
Jan 24 19:16
yes it's only toplevel views that have the problem I believe
i tested before with the pages in the control catalog, but i'll do some more testing
Nikita Tsukanov
@kekekeks
Jan 24 19:23
@grokys see PM
ahopper
@ahopper
Jan 24 21:15
Is there a neat way for a ScrollPanel to hide a scrollbar when not needed but not release the space for it when hidden?
Matthew Leibowitz
@mattleibow
Jan 24 21:37
@Gillibald I think I got everything: Gillibald/SkiaSharp#1
I got a PR against your branch so you can merge and continue working
James Burnside
@JCBurnside
Jan 24 21:39
I must be binding to it wrong. The set isn't being triggered. <Canvas Bounds="{Binding CanvasBounds, Mode=OneWayToSource}"/>
Steven Kirk
@grokys
Jan 24 21:49
@JCBurnside indeed. i just tried it and it doesn't seem to work. may be broken :/
investigating now
James Burnside
@JCBurnside
Jan 24 21:51
:thumbsup:
Steven Kirk
@grokys
Jan 24 21:57
ah. seems portable.xaml is refusing to apply the binding because Bounds is read-only, not realising that you can actually apply a binding to a read-only property if it's OneWayToSource
not sure if this is a bug in portable.xaml or if we need to override some behavior in our xaml layer
will have to try and work out how this works in WPF
James Burnside
@JCBurnside
Jan 24 22:17
I just realized that WPF doesn't have the bounds prop on it's canvas. is Bounds Avalonia specific?
Steven Kirk
@grokys
Jan 24 22:25
yeah it's ActualWidth/ActualHeight in WPF
however it doesn't work there either
image.png
so yeah looks like this is by design
ahopper
@ahopper
Jan 24 22:26
does Bounds.Width also fail?
Steven Kirk
@grokys
Jan 24 22:27
<Canvas Bounds.Width="{Binding CanvasBounds, Mode=OneWayToSource}"/>?
i don't think that will work
ahopper
@ahopper
Jan 24 22:27
I guess not
Steven Kirk
@grokys
Jan 24 22:27
it'll be looking for an attached property of the class Bounds
Benedikt Stebner
@Gillibald
Jan 24 22:27
@mattleibow Thanks will merge that tomorrow
Steven Kirk
@grokys
Jan 24 22:29
@JCBurnside here is a SO question that discusses the problem for WPF https://stackoverflow.com/questions/1083224/pushing-read-only-gui-properties-back-into-viewmodel
ahopper
@ahopper
Jan 24 22:32
Looks like another opportunity to be better than wpf.
Steven Kirk
@grokys
Jan 24 22:50
i think it's a XAML limitation tbh
you can totally do it from code
XAML has the concept of read-only for a member. but that can't be queried together with the value: i.e. you can't say "this member is readonly except for in this case"
James Burnside
@JCBurnside
Jan 24 23:05
that is slightly annoying... if they are readonly from code behind then shouldn't it be able to read from a binding.
Steven Kirk
@grokys
Jan 24 23:11
thing is, as far as XAML is concerned you're assigning that binding to the property
it doesn't have the concept itself of one way to source bindings
there may be a way to allow this by customizing the schema somehow, but i'm not really familiar enough with the dark undocumented corners of xaml to be able to say
Jeremy Koritzinsky
@jkoritzinsky
Jan 24 23:14
@grokys I think @danwalmsley opened an issue related to read-only XAML properties a while back that I commented on.
James Burnside
@JCBurnside
Jan 24 23:15
this one? #1658
Steven Kirk
@grokys
Jan 24 23:16
ah yes, looks like you've already been there @jkoritzinsky
given that it's a limitation of XAML i'm not sure there's much we can do
well, we could add an extension to portable.xaml but then what if we want to move to system.xaml?
ahopper
@ahopper
Jan 24 23:18
Might be an issue to pass onto wpf os
Steven Kirk
@grokys
Jan 24 23:19
yeah