These are chat archives for AvaloniaUI/Avalonia

18th
May 2018
Peter Worden
@Sn3akyP3t3_gitlab
May 18 2018 00:35
@danwalmsley I'm going to repair install visual studio 2017 at home tomorrow. Looks like something is hosed up with netcore 2 based projects. I did a vanilla netcore 2 project and got the same error dialog.
Jumar Macato
@jmacato
May 18 2018 01:41
@danwalmsley @grokys I just saw the review, i hope i can get to it later in the day
Regarding the Syntax, i prefer the Animations -> KeyFrame- > Setter version since it's much nicer compared to what i have implemented now
but i'd need to have some kind of one time preprocessor to convert that syntax into the relevant animators (what i call the ___KeyFrames classes) objects
in order to not have significant runtime reflection overhead that i tried to avoid :)
Jumar Macato
@jmacato
May 18 2018 03:24
i think this syntax is quite good and can be implemented in a jiffy
<Animation Duration="0:0:0.5">
  <KeyFrame Cue="0%">
    <Setter Property="Opacity" Value="0"/>
    <Setter Property="ScaleTransform.Scale" Value="0.1"/>
    <Setter Property="RotateTransform.Angle" Value="30"/>
  </KeyFrame>
  <KeyFrame Cue="50%">
    <Setter Property="RotateTransform.Angle" Value="-10"/>
  </KeyFrame>
  <KeyFrame Cue="70%">
    <Setter Property="RotateTransform.Angle" Value="3"/>
  </KeyFrame>
  <KeyFrame Cue="100%">
    <Setter Property="Opacity" Value="1"/>
    <Setter Property="ScaleTransform.Scale" Value="1"/>
  </KeyFrame>
</Animation>
Jumar Macato
@jmacato
May 18 2018 03:49
i think we will need a Type Registry to map the Animators to the target type in keyframes
the same should also be done with Easing types
Steven Kirk
@grokys
May 18 2018 05:37
for the moment it might be better just to hardcode them
type registries can be a bit difficult because you need to make static ctors run
oh i get you - we'd need them for the target types too, hmm
Jumar Macato
@jmacato
May 18 2018 05:40
hmm, hardcoding them will do sir but i was hoping that we could do a better solution so that we'd have less headaches when someone wants their own animator object
Steven Kirk
@grokys
May 18 2018 05:40
how would you ensure that types were registered?
Jumar Macato
@jmacato
May 18 2018 05:41
hmm, a similar thing that we did on TypeConverters perhaps?
Steven Kirk
@grokys
May 18 2018 05:42
yeah that could work
Jumar Macato
@jmacato
May 18 2018 05:42
or have a service that will scan the whole assembly
for certain types and with certain Attributes
on them
like what i am doing on the Easing types now
Steven Kirk
@grokys
May 18 2018 05:43
yeah attributes might be the best option
you need to be careful about scanning all assemblies as that can cause all assemblies to load, which might annoy users
Jumar Macato
@jmacato
May 18 2018 05:44
indeed sir, it was a stopgap measure on my end. i was hoping someone has a better way of doing that
Rayyan Tahir
@RayyanTahir
May 18 2018 05:45
@danwalmsley did you get the chance to test Popup's VerticalOffset and HorizontalOffset?
Steven Kirk
@grokys
May 18 2018 05:45
@jmacato regarding the ScaleTransform.Scale property, we'd need to decide if we want both Scale, ScaleX and ScaleY or whether we could just have Vector Scale { get; set; }
so lets maybe leave that until after
Jumar Macato
@jmacato
May 18 2018 05:46
i'd prefer the vector version for less brevity in code but yeah, that's for later i guess
Steven Kirk
@grokys
May 18 2018 05:47
yeah the problem with the vector version is that binding e.g. just X becomes difficult
Jumar Macato
@jmacato
May 18 2018 05:49
and with the Scale+ScaleX+ScaleY, we'd need to ensure that Scale or ScaleX+Y are mutual exclusively set
like what i did with Cue & KeyTime perhaps?
im currently hunting down the exception with GetKFPairAndIntraKFTimethat you encountered sir
Steven Kirk
@grokys
May 18 2018 05:52
yeah, the scale stuff would need a bit of thinking about
you can repro that error?
Jumar Macato
@jmacato
May 18 2018 05:52
i'm just getting on it now
i'll build avalonstudio, can't keep deleting MonoMac so that omnisharp works for the whole repo :/
i'll be right back sir
Rayyan Tahir
@RayyanTahir
May 18 2018 06:12
When I click on a TextBox with PasswordChar I get the following exception:
Message: Object reference not set to an instance of an object.
StackTrace:
   at Avalonia.Controls.Presenters.TextPresenter.CreateFormattedText(Size constraint, String text)
   at Avalonia.Controls.TextBlock.get_FormattedText()
   at Avalonia.Controls.Presenters.TextPresenter.GetCaretIndex(Point point)
   at Avalonia.Controls.TextBox.OnPointerPressed(PointerPressedEventArgs e)
   at Avalonia.Interactivity.RoutedEvent`1.<>c__DisplayClass1_0`1.<AddClassHandler>b__0(Object sender, RoutedEventArgs e)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Avalonia.Interactivity.RoutedEvent.<>c__DisplayClass25_0.<AddClassHandler>b__0(Tuple`2 args)
   at System.Reactive.AnonymousObserver`1.OnNextCore(T value)
   at System.Reactive.ObserverBase`1.OnNext(T value)
   at System.Reactive.Observer`1.OnNext(T value)
   at System.Reactive.Subjects.Subject`1.OnNext(T value)
   at Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
   at Avalonia.Input.MouseDevice.MouseDown(IMouseDevice device, UInt32 timestamp, IInputElement root, Point p, MouseButton button, InputModifiers inputModifiers)
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawMouseEventArgs e)
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawInputEventArgs e)
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e)
   at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e)
   at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Application.Run(ICloseable closable)
   at Avalonia.Controls.AppBuilderBase`1.Start[TMainWindow](Func`1 dataContextProvider)
   at OneScreenSwap.Program.Main(String[] args) in C:\Projects\SwapProxy\trunk\SwapClient\OneScreenSwap\OneScreenSwap\OneScreenSwap\Program.cs:line 13

Code for bordered textbox:
XAML

<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Height="40" Width="150">
  <Grid Name="ControlGrid">
    <Border Name="BorderControl" BorderBrush="#C9D4DC" BorderThickness="1">
      <Grid>
        <TextBox Name="txt" Margin="0,0,0,1" FontSize="15" VerticalAlignment="Center" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="Transparent" Foreground="#325E7C" BorderThickness="0"/>
        <TextBlock Name="lbl" IsVisible="False" Text="Some error" VerticalAlignment="Center" Margin="5,0,0,0" Height="{Binding Path=ActualHeight, RelativeSource={RelativeSource TemplatedParent}}" Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource TemplatedParent}}" Focusable="True" FontSize="13" Background="White" Foreground="#ED1300"/>
      </Grid>
    </Border>
  </Grid>
</UserControl>

C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using OneScreenSwap.Helper_Classes;
using OneScreenSwap.Models;
using System;

namespace OneScreenSwap.UserControls
{
    public class BorderedTextBox : UserControl
    {
        public delegate void TextHandler(String NewValue);
        public event TextHandler TextChanged;
        public bool HasError;
        TextBox txt;
        TextBlock lbl;
        Border BorderControl;
        public static readonly AttachedProperty<char> PasswordCharProperty = AvaloniaProperty.RegisterAttached<BorderedTextBox, char>("PasswordChar", typeof(BorderedTextBox));
        public char PasswordChar
        {
            get { return GetValue(PasswordCharProperty); }
            set { SetValue(PasswordCharProperty, value); }
        }
        public String Text
        {
            get { return (txt.Text == null ? string.Empty : txt.Text); }
            set { txt.Text = value; }
        }
        public static readonly AttachedProperty<String> HintProperty = AvaloniaProperty.RegisterAttached<BorderedTextBox, string>("Hint", typeof(BorderedTextBox), string.Empty);
        public String Hint
        {
            get { return GetValue(HintProperty); }
            set { SetValue(HintProperty, value); }
        }
        public static readonly AttachedProperty<TextBoxType> TextBoxTypeProperty = AvaloniaProperty.RegisterAttached<BorderedTextBox, TextBoxType>("TextBoxType", typeof(BorderedTextBox), TextBoxType.FreeText);
        public TextBoxType TextBoxType
        {
            get { return GetValue(TextBoxTypeProperty); }
            set { SetValue(TextBoxTypeProperty, TextBoxType); }
        }

        public delegate void OnFocusLostValidation(string InputText);
        public event OnFocusLostValidation OnFocusLostValidationEvent;
        public BorderedTextBox()
        {
            this.InitializeComponent();
            txt = this.FindControl<TextBox>("txt");
            lbl = this.FindControl<TextBlock>("lbl");
            BorderControl = this.FindControl<Border>("BorderControl");
            BorderControl.LostFocus += BorderControl_LostFocus;

            txt.TextInput += (s, e) =>
            {
                Text = txt.Text;
            };
            txt.PropertyChanged += (s, e) => 
            {
                if(e.Property == TextBox.TextProperty)
                {
                    TextChanged?.Invoke(Text);
                }
            };
            this.PointerPressed += LineTextBox_PointerPressed;
            txt.LostFocus += LineTextBox_LostFocus;
            txt.GotFocus += LineTextBox_GotFocus;
            this.GetObservable(HintProperty).Subscribe(value =>
            {
                txt.Watermark = value;
            });
            this.GetObservable(PasswordCharProperty).Subscribe(value => 
            {
                txt.PasswordChar = PasswordChar;
            });
        }
        public void ValidatePasswords(string Password)
        {
            if (!new ValidationService().Validate(Text, TextBoxType.ConfirmPassword, Password).Succeeded)
            {
                SetError(new Validatio
Rayyan Tahir
@RayyanTahir
May 18 2018 07:04
I'm trying to ShowDialog an alertwindow that returns a result. But the window gets indefinitely stuck with white background (no controls are rendered). Am I missing something?
var result = alert.ShowDialog<AlertWindow.AlertResult>().Result;
Steven Kirk
@grokys
May 18 2018 07:30
@RayyanTahir you shouldn't be accessing .Result like that, that's blocking
you need to do var result = await alert.ShowDialog<AlertWindow.AlertResult>();
by calling .Result you're blocking the UI thread
Rayyan Tahir
@RayyanTahir
May 18 2018 07:32
Yeah, I figured it out using:
Dispatcher.UIThread.InvokeAsync(async()=>{ //await ShowDialog here})
Steven Kirk
@grokys
May 18 2018 07:32
is that because the method you're showing the dialog from can't be async?
if so you're probably best using .ContinueWith, e.g. alert.ShowDialog<AlertWindow.AlertResult>().ContinueWith(result => { /* process result here */ })
Rayyan Tahir
@RayyanTahir
May 18 2018 07:34
Ahh thanks!
Rayyan Tahir
@RayyanTahir
May 18 2018 07:34
Also @grokys about the above exception i shared, any thoughts?
new string(PasswordChar, Text.Length) should be new string(PasswordChar, Text?.Length ?? 0)
@danwalmsley :point_up:
Rayyan Tahir
@RayyanTahir
May 18 2018 07:38
Just curious, the default value for property Text of type String is an empty string in WPF for the most part I guess, is there any reason why it is null in Avalonia?
Steven Kirk
@grokys
May 18 2018 07:40
yeah that seems to be true. we should change our default value then
could you add an issue?
Rayyan Tahir
@RayyanTahir
May 18 2018 07:40
Sure, I'll add both of these in one issue
Steven Kirk
@grokys
May 18 2018 07:40
thanks!
Dariusz Komosiński
@MarchingCube
May 18 2018 07:47
@danwalmsley Thanks for testing my latest changes! I am aware that there is some slight issue when you are resizing fast. Could you record the issue you are experiencing ? I would like to know if it is the same as one I can repro locally.
Benedikt Schroeder
@Gillibald
May 18 2018 08:22
Is there a way to track and asign bugs to a certain person? Hard to keep track of things that have to be done or someone is currently working on. Should I fix bugs or keep introducing wanted features? Btw do we discuss wanted features in advance? If I would implement ShutdownMode now and just one person would want this and the majority doesn't all work would be wasted. Even having API proposals in advance would be nice.
Rayyan Tahir
@RayyanTahir
May 18 2018 08:36
@Gillibald isn't Window's Transparency an important feature to impl?
Steven Kirk
@grokys
May 18 2018 08:39
@Gillibald yes thanks for all your work on fonts!
and yeah it's best to discuss here first. there's not really a good way keeping track of who's working on what other than leaving a comment on an issue
as issues can only be assigned to core members, which kinda defeats the point in a project like this
regarding the fonts stuff, is it just the asset loader stuff that's blocking that?
i'd really like to not leave that PR hanging around open, it'd be best to get it merged
ShutdownMode would be a good thing to have i think
danwalmsley
@danwalmsley
May 18 2018 09:25
Just curious, the default value for property Text of type String is an empty string in WPF for the most part I guess, is there any reason why it is null in Avalonia?
once then next version of c# comes in with non-nullable reference types changing the default value from null to "" will probably be the kind of change we would have to make
and I guess it would have prevented this crash
i'll push a fix
Rayyan Tahir
@RayyanTahir
May 18 2018 09:26
Exactly :wink:
Thanks
Benedikt Schroeder
@Gillibald
May 18 2018 09:26
Only the part about AssetLoader is preventing it from getting merged. I would love to extend IAssetLoader so I can find resources at a location. I am a friend of decent solutions. This PR isn't about changing the way resources are accessed. We will find a way to improve that in the future.
danwalmsley
@danwalmsley
May 18 2018 09:27
@grokys that being said i'll put the null checks in as someone could bind to null
Benedikt Schroeder
@Gillibald
May 18 2018 09:28
Probably will just extend IAssetLoader and we can discuss if that's the right way.
IAssetLoader. GetResources(string expression)
This method could support wildcards as well. Not sure if we should pass a Uri to that method or just the Uri string. The current implementation doesn't use Uris
danwalmsley
@danwalmsley
May 18 2018 09:42
@grokys in unit test how do I trigger render pass?
[Fact]
        public void TextBox_can_contain_null_with_password_char_set()
        {
            using (UnitTestApplication.Start(Services))
            {
                var target = new TextBox
                {
                    PasswordChar = '*'
                };

                target.CaretIndex = 1;
            }
        }
Steven Kirk
@grokys
May 18 2018 09:54
@Gillibald yes i'd be :+1: with that solution
just use strings there as the rest of the API uses strings
danwalmsley
@danwalmsley
May 18 2018 10:01
@grokys is this unit test ok
[Fact]
        public void TextBox_can_contain_null_with_password_char_set()
        {
            using (UnitTestApplication.Start(TestServices.StyledWindow.With(focusManager: new FocusManager(),
            keyboardDevice: () => new KeyboardDevice(),
            keyboardNavigation: new KeyboardNavigationHandler(),
            inputManager: new InputManager())))
            {
                var root = new Window();
                var target = new TextBox
                {
                    PasswordChar = '*'
                };

                root.Content = target;

                root.ApplyTemplate();
                target.ApplyTemplate();
                target.Measure(Size.Empty);
                target.Arrange(Rect.Empty);


                target.Focus();
                target.CaretIndex = 1;

                RaiseKeyEvent(target, Key.Home, InputModifiers.None);
            }
        }
it repros the bug with password char
but doesn't have any assertions, its just looking for an exception
hmm im just realising this test can be made a lot simpler by testing textpresenter on its own
danwalmsley
@danwalmsley
May 18 2018 10:08
[Fact]
        public void TextPresenter_can_contain_null_with_password_char_set()
        {
            var target = new TextPresenter
            {
                PasswordChar = '*'
            };

            Assert.NotNull(target.FormattedText);
        }
much simpler
danwalmsley
@danwalmsley
May 18 2018 10:26
@grokys #1598 very simple fix and unit tests for the password char crash. (also found a bug that was hidden)
Jumar Macato
@jmacato
May 18 2018 10:27
@danwalmsley Animations PR's good to go :+1:
some of the nits are not yet fixed however..
danwalmsley
@danwalmsley
May 18 2018 10:30
@jmacato does it have the new syntax now?
@RayyanTahir #1598 will fix your crash
Jumar Macato
@jmacato
May 18 2018 10:31
ah no not yet, just the stuff sir @grokys requested like automagically adding transforms in controls
danwalmsley
@danwalmsley
May 18 2018 10:31
do you have repro code for your popup issue?
ah that's nice
Jumar Macato
@jmacato
May 18 2018 10:31
and removing the requirement for having start and end keyframes
it'll just use the prior value of the target as neutral keyframes
Rayyan Tahir
@RayyanTahir
May 18 2018 10:32
@danwalmsley the repro code for popup offset issue is in #1573
Jumar Macato
@jmacato
May 18 2018 10:33
the new syntax however will take some time, i hope that we can have a concensus on the final syntax before reimpl
all the backend code are good to go (excluding nits)
danwalmsley
@danwalmsley
May 18 2018 10:45
@grokys this
<Popup Name="popupWithOffset" HorizontalOffset="300" Width ="250" Height="100">
      <TextBlock Text="Popup with offset"/>
    </Popup>
after InitializeComponent HorizontalOffset is 0
could this have been properties overhaul?
danwalmsley
@danwalmsley
May 18 2018 11:01
@grokys looks like a fairly serious issue let me know where your around, its failing to set the property inside PriorityLevel and PriorityValue classes which I have no understanding of
V
Steven Kirk
@grokys
May 18 2018 11:07
the repro in the issue doesn't run for me
Main isn't even being hit
also it's targetting 0.6.1 stable
Rayyan Tahir
@RayyanTahir
May 18 2018 11:08
My bad, I created a repro targeting 0.6.1 stable, but its still troubling for latest pre-release
Steven Kirk
@grokys
May 18 2018 11:08
but the problem is there in 0.6.1 too?
Rayyan Tahir
@RayyanTahir
May 18 2018 11:09
Yes
danwalmsley
@danwalmsley
May 18 2018 11:12
@grokys i had same thing
Clean
And update to nightly
Then revuikd
Or better copy the popup xaml to control catalog you only need to define a popup with horizontal offset
In xaml
Then see that the property value remains zero after template has been applied
Rayyan Tahir
@RayyanTahir
May 18 2018 11:13
On the latest pre-release, I caught a weird behavior when setting AcceptsReturn = "True" for TextBox. Pressing Return key inside first adds an indent of (i think) 8 spaces and the next key press moves the caret to new line with indentation. See below gif for reference:
Weird AcceptsReturn TextBox.gif
Steven Kirk
@grokys
May 18 2018 11:15
ok, i've got to go to the dentist now
danwalmsley
@danwalmsley
May 18 2018 11:16
Which backend is that? Skia?
Steven Kirk
@grokys
May 18 2018 11:16
will look into it when i get back
Rayyan Tahir
@RayyanTahir
May 18 2018 11:16
I'm running it on Windows
danwalmsley
@danwalmsley
May 18 2018 11:16
Good luck @grokys .
Rayyan Tahir
@RayyanTahir
May 18 2018 11:33
How to remove this dotted border around a focused control:
image.png
danwalmsley
@danwalmsley
May 18 2018 11:41
add this to your style
obviously changing to something more apropriate
or with a selector for just TextBox
Rayyan Tahir
@RayyanTahir
May 18 2018 11:42
The style as is will be better so that it applies for all controls
danwalmsley
@danwalmsley
May 18 2018 11:48
so you can add something like:
<Style Selector="TextBox.myClass">
  <Setter Property="FocusAdorner" Value="" />
</Style>
just on your particular control
Jumar Macato
@jmacato
May 18 2018 11:51
@danwalmsley is it fine to just leave Value="" instead of Value="{x:Null}" ?
danwalmsley
@danwalmsley
May 18 2018 11:52
im also pondering that too
Iv been over this a while back but cant remember
I think x:Null sets it to null
and ="" means unset?
but don't quote me on that its only a vague recollection
Jumar Macato
@jmacato
May 18 2018 11:53
hmm i'm not sure? wouldn't be null either way?
yeah i am not sure about this too
danwalmsley
@danwalmsley
May 18 2018 11:54
@jmacato there is definitely a syntax for Unset (which is different to null)
as far as I remember
Jumar Macato
@jmacato
May 18 2018 11:54
i guess i just havent seen that in the wild yet
danwalmsley
@danwalmsley
May 18 2018 11:55
it might be that they are both null or ="" crashes
id have to test it
Jumar Macato
@jmacato
May 18 2018 11:56
alright, we need to doc this stuff up sometime
danwalmsley
@danwalmsley
May 18 2018 12:07
@RayyanTahir I cant get the focus adorner to display, do you have code to reproduce that?
Benedikt Schroeder
@Gillibald
May 18 2018 12:08
Any idea what is preventing us from using a code generator task to convert xaml to c#?
danwalmsley
@danwalmsley
May 18 2018 12:09
just someone to implement it
Jumar Macato
@jmacato
May 18 2018 12:10
@Gillibald cwensley/Portable.Xaml#41
and this issue specifically cwensley/Portable.Xaml#23
we could adapt that to service us? :)
danwalmsley
@danwalmsley
May 18 2018 12:17
@jmacato ok I tested
if you use DataContext="" then you get empty string as datacontext
if you use x:Null its null
Jumar Macato
@jmacato
May 18 2018 12:19
ohh... well that settles it then :smile:
could be useful for style setters in textboxes and whatnot
Benedikt Schroeder
@Gillibald
May 18 2018 12:19
This will probably speed up everything by a lot. Will be fun to build some prototype :)
danwalmsley
@danwalmsley
May 18 2018 12:19
in this case with focus adorner Unsetting it would mean it inherits the global one anyway
@Gillibald would be awesome!
Jumar Macato
@jmacato
May 18 2018 12:20
@Gillibald nice!
danwalmsley
@danwalmsley
May 18 2018 12:20
I think x:Null is whats needed most of the time
Jumar Macato
@jmacato
May 18 2018 12:20
right, i always use that, wasnt aware of the empty setter before
Wiesław Šoltés
@wieslawsoltes
May 18 2018 12:22
:+1: code generator task to convert xaml to c#
That would be huge :smile:
Jumar Macato
@jmacato
May 18 2018 12:23
@wieslawsoltes i forgot to tag you dude hahaha, we were raving about this a while back
Wiesław Šoltés
@wieslawsoltes
May 18 2018 12:23
yeah :smile:
The xaml loading is biggest bottleneck when developing my apps with AvaloniaUI
You can mitigate some parts, like using Carousel with IsVirtualized="False" but still initial load times are slow.
Jumar Macato
@jmacato
May 18 2018 12:29
@wieslawsoltes wow that's wacky and neat :laughing:
@wieslawsoltes btw, do you have any input regarding #1461 ?
I'd like to finalize the syntax before i do another reimplementation pass
Wiesław Šoltés
@wieslawsoltes
May 18 2018 12:32
I have no experience with animation, sorry
Jumar Macato
@jmacato
May 18 2018 12:32
alright, thanks anyway :smile:
Wiesław Šoltés
@wieslawsoltes
May 18 2018 12:37
Anyway nice work :smile:
I am busy with my docking control
Jumar Macato
@jmacato
May 18 2018 12:38
ah yeah, how's that goin btw
Wiesław Šoltés
@wieslawsoltes
May 18 2018 12:38
Slow
I have changed my design few times already
Jumar Macato
@jmacato
May 18 2018 12:38
aw :/
danwalmsley
@danwalmsley
May 18 2018 12:38
@wieslawsoltes sorry iv not had chance to get involved too much with that yet
@jmacato regarding the animation syntax to clarify...
Wiesław Šoltés
@wieslawsoltes
May 18 2018 12:39
That's actually a good thing, I have changed a lot of stuff many times
danwalmsley
@danwalmsley
May 18 2018 12:39
<Animation Duration="0:0:0.5">
  <KeyFrame Cue="0%">
    <Setter Property="Opacity" Value="0"/>
    <Setter Property="ScaleTransform.Scale" Value="0.1"/>
    <Setter Property="RotateTransform.Angle" Value="30"/>
  </KeyFrame>
  <KeyFrame Cue="50%">
    <Setter Property="RotateTransform.Angle" Value="-10"/>
  </KeyFrame>
  <KeyFrame Cue="70%">
    <Setter Property="RotateTransform.Angle" Value="3"/>
  </KeyFrame>
  <KeyFrame Cue="100%">
    <Setter Property="Opacity" Value="1"/>
    <Setter Property="ScaleTransform.Scale" Value="1"/>
  </KeyFrame>
</Animation>
that there is nicer because you can set multiple things on same cue
then this
Jumar Macato
@jmacato
May 18 2018 12:40
to all: any objections/suggestions to this syntax is welcomed :)
danwalmsley
@danwalmsley
May 18 2018 12:40
<KeyFrame Cue="0%" Content="Scale=0.1,Rotate=30,Opacity=1)" />
Jumar Macato
@jmacato
May 18 2018 12:40
@danwalmsley i really like the prior syntax
danwalmsley
@danwalmsley
May 18 2018 12:40
that is simply a typeconverter that parses a string into the above
its the samething that was done with RowDefinitions
Jumar Macato
@jmacato
May 18 2018 12:41
should we do both?
danwalmsley
@danwalmsley
May 18 2018 12:41
so you can do Grid RowDefinations="Auto,*Auto"
Jumar Macato
@jmacato
May 18 2018 12:41
but i reckon the latter shorthand syntax would be limited to the basic transform controls
danwalmsley
@danwalmsley
May 18 2018 12:41
well to do the second one you have to implement the first anyway
but i reckon the latter shorthand syntax would be limited to the basic transform controls
why?
Jumar Macato
@jmacato
May 18 2018 12:41
unless we do a type registry of some sort for handlers
danwalmsley
@danwalmsley
May 18 2018 12:42
my thoughts were if it sees Scale, Rotate or Skew
it does a transform
if it sees anything else, then it looks up the property
and if it doesn't find a property, it ignores it or throws an exception
the only disadvantage is intellisense
that's why I was thinking of markup extension
Jumar Macato
@jmacato
May 18 2018 12:42
i resorted to warning log like bindings
danwalmsley
@danwalmsley
May 18 2018 12:43
warnings better I think
Jumar Macato
@jmacato
May 18 2018 12:43
i already implemented that in the prev. commit
hmm
danwalmsley
@danwalmsley
May 18 2018 12:43
I cant think of a way to make it simpler than that though
Jumar Macato
@jmacato
May 18 2018 12:45
i mean, how should we determine whether Scale & etc are Transforms or Properties?
in the shorthand
because in the long form, i can just pull the Property.OwnerType and get along with it
danwalmsley
@danwalmsley
May 18 2018 12:46
I think give properies priorirty
Jumar Macato
@jmacato
May 18 2018 12:46
the only solution that i see is that we will have some kind of type registry that maps the keys
to the handlers
hmm
danwalmsley
@danwalmsley
May 18 2018 12:47
then shorthands it just expands to ScaleTransform.Scale
you could have Scale, ScaleX, ScaleY in the shorthand
it would be something like KeyFrame.Parse ("") method or something perhaps
but I don't know how this affect the underlying code so im only coming from a end user perspective
Jumar Macato
@jmacato
May 18 2018 12:48
right, it's a getting bit complex when i factor in future customizability over
convenience..
but i'll think about the right approach on this one
danwalmsley
@danwalmsley
May 18 2018 12:50

right, it's a getting bit complex when i factor in future customizability over

how would this prevent that?

Jumar Macato
@jmacato
May 18 2018 12:52
example, given CustomTransform.CustomProperty, and the on the shorthand it was declared as CustomProperty=somevaluehere
how should the preprocessor know that CustomProperty is for a transform of the target?
hence the need for a some kind of registry
danwalmsley
@danwalmsley
May 18 2018 12:54
ah right I get it now
i guess something similar to typeconverters?
gets registered
and if no converter is found then it simply gives a warning
not a simple as it first appeared then
this is the case for shorthand and the more verbose though?
Jumar Macato
@jmacato
May 18 2018 12:58
yes
the long form doesnt have this problem since
Ambients provide for the necessary types
the long form is just an rearrangement of the current setup in the PR ;)
tho i implemented it the way it was now because of my rusty css skills , and a holdover in wpf, i guess :laughing:
danwalmsley
@danwalmsley
May 18 2018 13:03
maybe do the longform and then we can figure out shorthand later
plus i would like to experiment with markup extensions see if we can do an intellisense compatible way
Jumar Macato
@jmacato
May 18 2018 13:03
sure, that'll be awesome :smile:
i'd like to learn more about markup extensions anyway
i'll wait for sir @grokys 's input then i'll proceed
and btw, havent got to fix all the nits in review just yet, i'll try to finish them up today :)
Steven Kirk
@grokys
May 18 2018 14:33
@danwalmsley @RayyanTahir AvaloniaUI/Avalonia#1599 should fix the popup issue
CodeMyst
@CodeMyst
May 18 2018 14:35
Is this a good place to ask question about issues with Avalonia? Never used gitter so I'm not quite sure :sweat_smile:
Steven Kirk
@grokys
May 18 2018 14:36
yes it is @CodeMyst !
welcome
CodeMyst
@CodeMyst
May 18 2018 14:38

:D

I'm using Avalonia for the first time and trying to do MVVM binding.

Binding some text works:

<TextBlock
    Text="{Binding StatusText}"/>

Now I wanted to change the StatusText from a button click. I got the button Command binding to work, but changing the StatusText property doesn't reflect to the UI. Any clues as to why this is?

The Login method does get called (prints to the console) but StatusText doesn't get changed in UI.
public class MainWindowViewModel : ViewModelBase
{
    public string StatusText { get; set; }

    public MainWindowViewModel ()
    {
        StatusText = "Status: off";
    }

    public void Login ()
    {
        StatusText = "Status: on";
        System.Console.WriteLine("BUTTON");
    }
}
Steven Kirk
@grokys
May 18 2018 14:39
ok, you need to make sure you raise property changed events for StatusText
otherwise avalonia doesn't know that the property has changed
change your property to read:
string statusText;
public string StatusText 
{ 
    get => statusText;
    set => this.RaiseAndSetIfChanged(ref statusText, value); }
}
we need to add that info to the docs!
CodeMyst
@CodeMyst
May 18 2018 14:43
Ahh. Thank you @grokys ! It works now. Yeah, it should be added to the docs
Steven Kirk
@grokys
May 18 2018 14:43
yeah sorry, our docs are very much an early WIP
CodeMyst
@CodeMyst
May 18 2018 14:44
I've noticed haha. But I did some UWP apps before so it's easier.
Jumar Macato
@jmacato
May 18 2018 15:03
@grokys @danwalmsley i would also need a type registry for the new syntax (short/long form); i am not sure on how to approach this one
but i propose the following:
  1. Add an overridable method on App class so that the user can register the custom animation handler types that the user want (preferrably this can be called before parsing starts)
  2. Do it like what i'm doing with Easings : Scan the calling assembly for all the public types and select the relevant types via patterns
Steven Kirk
@grokys
May 18 2018 15:29
i don't like scanning assemblies so much because it can cause everything to be loaded upfront
though tbh i think we're already doing it on net framework
Jumar Macato
@jmacato
May 18 2018 15:36
it'll be better to run the scan once and cache it for future use sir; it's a powerful method for extensibility imho but like you said sir, it'll load everything upfront, i guess
CodeMyst
@CodeMyst
May 18 2018 15:59
Is it possible to change the visibility of an element? Looks like it doesn't have the Visibility property.
Jumar Macato
@jmacato
May 18 2018 16:00
IsVisible is a boolean property used for controls in Avalonia for visibility :)
CodeMyst
@CodeMyst
May 18 2018 16:00
Yup, it works. Thanks :smile:
Jumar Macato
@jmacato
May 18 2018 16:01
Alright :smile:
Benedikt Schroeder
@Gillibald
May 18 2018 16:42
Can't stop thinking about making code generation happen. Just have to play a bit with Roslyn. Have to figure out if we need some IL magic or not. Depends on how the generated partial class will look like. Maybe this can be optional like xamarin forms does it.