These are chat archives for AvaloniaUI/Avalonia

29th
Nov 2018
Kermalis
@Kermalis
Nov 29 2018 06:49
When a line's start and end point are the same, it bleeds sideways for some reason
image.png
the x and y are in the center of that vertical line it's piercing through
It looks fine when the endpoint x is greater than the startpoint x though:
image.png
    <Line StartPoint="49,18" EndPoint="{Binding HPEndLocation}" Stroke="{Binding HPColor}" StrokeThickness="3" ZIndex="1"/>
Kermalis
@Kermalis
Nov 29 2018 06:56
Should I create an issue? This is one of many issues related to drawing I'm facing
Nikita Tsukanov
@kekekeks
Nov 29 2018 07:03
I guess it assumes that line has vertical direction
And tries to render it with StrokeThickness=3
Nikita Tsukanov
@kekekeks
Nov 29 2018 08:19

@jkoritzinsky @grokys
Remember

static void Main(string[] args)
{
       // Avalonia isn't set up at this point, don't use *anything* UI-related here (including your view models)
       BuildAvaloniaApp().Start(AppMain, args);
}

static void AppMain(App app, string[] args)
{
      app.Run(new MainWindow());
}

?

That will require a huge refactor of AppBuilder
To provide a typed App instance
Currently we are using type param only in Configure<TApp>() method
And then it's lost
Basically that would require a split of AppBuilder
Into AppBuilder and AppBuilderInstance
Or we would have to parametrize AppBuilder<T>
Nikita Tsukanov
@kekekeks
Nov 29 2018 08:25
Nope, would be broken in a lot of ways
I think I'll introduce Start<TApp> method
And cast in runtime
Nope, doesn't work either
Type inference isn't smart enough
Nikita Tsukanov
@kekekeks
Nov 29 2018 08:36
Steven Kirk
@grokys
Nov 29 2018 10:08
thanks @kekekeks will try to fix #2147 asap
Nikita Tsukanov
@kekekeks
Nov 29 2018 10:29
DrawingPresenter seems to have a weird interaction with DockPanel
It occupies the entire space
Even if placed in a button
Nikita Tsukanov
@kekekeks
Nov 29 2018 10:46
Is there some control that completely ignores child measures?
@grokys
Steven Kirk
@grokys
Nov 29 2018 10:47
can you give an example?
Canvas completely ignores child measures I think
Nikita Tsukanov
@kekekeks
Nov 29 2018 10:50
It also doesn't arrange them automatically
    class ChildFitter : Decorator
    {
        protected override Size MeasureOverride(Size availableSize)
        {
            return new Size(0, 0);
        }
    }
I have to use this as a workaround for DrawingPresenter in DockPanel issue
Otherwise DockPanel asks DrawingPresenter if it can use the entire available size
And it happily does
Steven Kirk
@grokys
Nov 29 2018 11:04
ok, sounds like the measure for DrawingPresenter is wrong
it should only be asking for the size of the drawing
i'm not very familiar with DrawingPresenter
Nikita Tsukanov
@kekekeks
Nov 29 2018 11:07
The thing is that I want to have a button right to the textbox
And want that button to be square and have the same height the textbox does
And I want an image to stretch itself to fill the button, whatever size it has
BTW, Binding to ActualHeight doesn't seem to work
Steven Kirk
@grokys
Nov 29 2018 11:08
we don't have ActualHeight
Nikita Tsukanov
@kekekeks
Nov 29 2018 11:09
Ouch
Steven Kirk
@grokys
Nov 29 2018 11:09
use Bounds.Height
Nikita Tsukanov
@kekekeks
Nov 29 2018 11:09
Does Binding properly recognize Rect being a struct?
Steven Kirk
@grokys
Nov 29 2018 11:09
it should!
Nikita Tsukanov
@kekekeks
Nov 29 2018 11:09
If I remember correctly, WPF has major issues with types not implementing INPC
Steven Kirk
@grokys
Nov 29 2018 11:09
Rect is immutable
anyway, what should happen with DrawingPresenter is that it should report the natural size of the drawing on measure. then on arrange, it should scale the drawing according to Stretch. so if Stretch is set to Uniform then it should preserve the aspect ratio of the drawing, doing what you want i believe
Try to create this layout using DockPanel and DrawingPresenter inside a button
I have failed to do so without and extra control with custom measureoverride
Steven Kirk
@grokys
Nov 29 2018 11:30
@kekekeks yep i've looked at the code. DrawingPresenter's layout is broken - it doesn't override ArrangeOverride to apply the Stretch
we really need to remove DrawingPresenter and get Image working with drawings. it was a hacky quick fix
Nikita Tsukanov
@kekekeks
Nov 29 2018 11:32
Do we have some kind of keyboard search support for our listboxes?
Steven Kirk
@grokys
Nov 29 2018 11:33
not yet
we should add an issue for that
Nikita Tsukanov
@kekekeks
Nov 29 2018 11:42
chooser.gif
I guess we could live without theme icons and mountable locations for now
Pavel Zhdanovich
@SWATOPLUS
Nov 29 2018 13:53
Hi guys, I have a problem with SaveFileDialog
изображение.png
Benedikt Schroeder
@Gillibald
Nov 29 2018 13:56
Why are you passing null as the parent and why aren't you marking your method async and just await the ShowAsync call?
If you only have one window you can use Application.Current.MainWindow
Pavel Zhdanovich
@SWATOPLUS
Nov 29 2018 13:57
Clicking at the button starts this code. It shows me default windows save file dialog. Atfer selection of place to save file, program hangs out and this breakpoint doesn't triggered. What do I doing wrong?
изображение.png
Benedikt Schroeder
@Gillibald
Nov 29 2018 13:59
Try to await it properly.
Pavel Zhdanovich
@SWATOPLUS
Nov 29 2018 14:01
Fix upper don't solve the problem, after that program hangs out w/o opeing dialog window
How can I bind event from xaml to async Task Method?
@Gillibald ?
I take this Exception when I change it to async Task. Portable.Xaml.XamlObjectWriterException: 'Could not convert object 'Save_Click' (of type System.String) to {clr-namespace:System;assembly=mscorlib}EventHandler({clr-namespace:Avalonia.Interactivity;assembly=Avalonia.Interactivity}RoutedEventArgs): Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.'
изображение.png
Pavel Zhdanovich
@SWATOPLUS
Nov 29 2018 14:07
@grokys @kekekeks ?
ahopper
@ahopper
Nov 29 2018 14:11
have you tried async void ? I believe that is still acceptable for event handlers.
Nikita Tsukanov
@kekekeks
Nov 29 2018 14:42
Event handlers should be async void
@grokys we really need our own task-like that throws exceptions when non awaited
Nikita Tsukanov
@kekekeks
Nov 29 2018 14:47
Well, I guess people will wrap it in async Task and try to get result synchronously from there
Pavel Zhdanovich
@SWATOPLUS
Nov 29 2018 16:19
So, async void works correct. But as I undestand it is bad practice.
Jeremy Koritzinsky
@jkoritzinsky
Nov 29 2018 16:19
It's ok for event handlers. This is the situation for why it was allowed in the first place.
Pavel Zhdanovich
@SWATOPLUS
Nov 29 2018 16:23
Ok. I have another question.
I place a TextBox control
<TextBox Grid.Row="0" Grid.Column="0" x:Name="Editor"></TextBox>
Next I created a readonly property at constructor
Editor = this.FindControl<TextBox>(nameof(Editor));
jp2masa
@jp2masa
Nov 29 2018 16:26
try Name instead of x:Name
Pavel Zhdanovich
@SWATOPLUS
Nov 29 2018 16:26
Then, when I get access to the text property it returns null, but I expecting a empty string
File.WriteAllText(fileName, Editor.Text);
Is it a correct behaviour?
Nikita Tsukanov
@kekekeks
Nov 29 2018 16:29
We have checks for Text property being null
So it seems to be intended behaviour
Not sure if it's correct one
Pavel Zhdanovich
@SWATOPLUS
Nov 29 2018 16:34
Maybe you should create an issue about this? Or it's intentionally?
try Name instead of x:Name
So, both work.
But what is correct one? (recommended way)
Nikita Tsukanov
@kekekeks
Nov 29 2018 16:54
x:Name is more "standardized"
We have Name from OmniXAML times
Since OmniXAML didn't support standard xaml namespaces
Nikita Tsukanov
@kekekeks
Nov 29 2018 17:56
Do we have some kind of "wrap when needed, otherwise act like a grid row" panel?
i. e.
[Control at the left] ----- Empty space ----- [Control at the right]
When there is no enough space, it should work like a horizontal StackPanel
ahopper
@ahopper
Nov 29 2018 18:10
my next job is a wrap when needed panel using minWidth but then give items all the spare space on a row.
Benedikt Schroeder
@Gillibald
Nov 29 2018 19:22
Are pointer events routed events? I don't understand why a control needs to calculate the visuals in one area when performing hit testing. Shouldn't the event bubbleing / tunneling to the controls in one specific area until the event is handled?
Nikita Tsukanov
@kekekeks
Nov 29 2018 19:33
If you press mouse over a button
And move it out of the button before releasing
Button shouldn't be considered clicked
Steven Kirk
@grokys
Nov 29 2018 20:24
hmm we fixed that bug in Button, is it back?
Steven Kirk
@grokys
Nov 29 2018 20:31
@kekekeks just tried and seems to work correctly
do you have any more repro?
Nikita Tsukanov
@kekekeks
Nov 29 2018 20:49
Recent master, Skia, Linux
I've provided a screenshot
Andrey Kunchev
@donandren
Nov 29 2018 20:57
@grokys i'll give you easy repro for button click in control catalog in issue comments
@grokys @kekekeks issue #2148 is valid only for defered renderer as hit testing in defered renderer is only for controls been rendered e.g. has background or border, immediate renderer should work fine tough
Nikita Tsukanov
@kekekeks
Nov 29 2018 21:05
It correctly finds the textblock via hittest
It's just TextBlock that has TemplatedParent == null
ListBox.ScrollIntoView scrolls exactly to the next element
Has anyone encountered that?
That's frustrating
Andrey Kunchev
@donandren
Nov 29 2018 21:10
@kekekeks AvaloniaUI/Avalonia#2134 very similar issue or may be the same
ahopper
@ahopper
Nov 29 2018 21:14
certainly behavior near the end of the list is odd and the code is a bit hairy in my opinion.
Nikita Tsukanov
@kekekeks
Nov 29 2018 21:19
I'm experiencing issues with elements in the middle of the list
ahopper
@ahopper
Nov 29 2018 21:20
is this when calling ScrollIntoView from code?
danwalmsley
@danwalmsley
Nov 29 2018 21:24
@jmacato the datagrid control does it handle things like sorting by a particular column?
does it also support virtualization?
ahopper
@ahopper
Nov 29 2018 21:25
with the current code in master I think you can get different results depending if a recent action was to scroll to the bottom of the list
Nikita Tsukanov
@kekekeks
Nov 29 2018 21:34

is this when calling ScrollIntoView from code?

Yes

I'm trying to scroll to a certain element after showing the window
I'm using await Task.Delay(100) to wait for layout to complete
Then I call ScrollIntoView
BTW, is there any way to preview and cancel ListBox selection?
ahopper
@ahopper
Nov 29 2018 21:38
I think I once found I could bind to selectedItem and then set it to null to cancel.
Nikita Tsukanov
@kekekeks
Nov 29 2018 21:40
There is Validate method on AvaloniaList
But it can only throw exception
Would be a perfect place to cancel selection, I think
ahopper
@ahopper
Nov 29 2018 21:45
slightly odd for the ui to offer an option and then say sorry, I'm sure you have a reason, but it strikes me it might be nice to have the option of unselectable/grayed out options in a list.
Steven Kirk
@grokys
Nov 29 2018 21:50
i was thinking of adding SelectionMode.None which would only allow selection to be made from code
would that help?
btw why do you want to cancel ListBox selection @kekekeks? i'd like to hear of use-cases
two that i can think of are 1. like @ahopper says: disabled items in a list and 2. using items as headers
Nikita Tsukanov
@kekekeks
Nov 29 2018 21:56
Use case: File selection dialog in multiselect mode shouldn't allow selecting directories
Only files
When user click on a directory ListBox adds it to selection
Right now I have to subscribe to Collection changed and use Dispatcher.InvokeAsync to properly post-validate selection
Directory is by no means "disabled"
Double click on it makes file dialog enter said directory
ahopper
@ahopper
Nov 29 2018 22:03
directory could still be treated as unselectable
Steven Kirk
@grokys
Nov 29 2018 22:03
ah ok, yes that's interesting @kekekeks - we could definitely add an event for that
like a SelectionChanging event with a e.Cancel property or something?
googling for the solution in WPF, a lot of users seem to be missing such a feature