These are chat archives for AvaloniaUI/Avalonia

9th
May 2018
rconde01
@rconde01
May 09 2018 01:24
“From a 1000-meter view, you can think of WPF as a rich layer over DirectX and Windows Forms as thinner layer over GDI Plus. WPF and Windows Forms do a great job of exposing and exercising much of the desktop application functionality in Windows. It’s the C# code in Windows Forms and WPF that we’ll include as a set of libraries with .NET Core 3. Windows functionality, like GDI Plus and DirectX, will remain in Windows.”
The way that’s worded, it kinda sounds like you should just be able to provide a backend to replace directx
Btw Avalonia gets called out a lot in the comments
Benedikt Schroeder
@Gillibald
May 09 2018 02:26
@jkoritzinsky Most of the time Courier New was used as a default font so i adapted that.
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 02:26
@Gillibald sounds good to me!
Benedikt Schroeder
@Gillibald
May 09 2018 02:27
@danwalmsley I will try more complex path scenarios. I realised that it is sometimes difficult to get the path right but thats because of namespaces
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 02:29
@rconde01 it's not that easy. There's a LOT of Windows-specific code throughout all of WPF, not just in rendering. The reason we can support multiple backends is because we started to design around that being a feature years ago. There's a reason they call it a 1000-meter view.
Like even in the text caret drawing support there's Win32 specific code for accessibility.
ahopper
@ahopper
May 09 2018 09:52

Binding to elements up the tree from inside an ItemsControl DataTemplate does not seem to work

<Button Classes="LinkButton" Command="{Binding #ftgrid.DataContext.SpotSelectedCommand}"
                       CommandParameter="{Binding}" >

Is this by design or a bug? I can achieve what I want with $parent[x] but that seems less robust

ftgrid is outside the ItemsControl
Rayyan Tahir
@RayyanTahir
May 09 2018 11:05
C# way to set Background property of a Control to an ImageBrush of a png from Assets folder?
In WPF its: SomeGrid.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Content/Images/bg.png")));
ahopper
@ahopper
May 09 2018 11:12
dont know if this helps resm:ControlCatalog.Assets.delicate-arch-896885_640.jpg but that is typical for getting a resource
Rayyan Tahir
@RayyanTahir
May 09 2018 11:14
We would generally use that in XAML, can't find a way to do it from C# end. Thanks though
Steven Kirk
@grokys
May 09 2018 11:24
@ahopper what does your data template look like exactly?
ahopper
@ahopper
May 09 2018 11:39

@grokys

<TabItem Header="Spots" Background="Green">
          <Grid RowDefinitions="auto,*" HorizontalAlignment="Left" name="ftgrid">
            <StackPanel Orientation="Horizontal" Background="LightGray" >
              <TextBlock Margin="8,0,0,0" Width="130">Time</TextBlock>
              <TextBlock Width="70">Freq</TextBlock>
              <TextBlock Width="30">snr</TextBlock>
              <TextBlock Width="30">dt</TextBlock>
              <TextBlock Width="50">Mode</TextBlock>
              <TextBlock Width="50">Distance</TextBlock>
              <TextBlock Width="140">Message</TextBlock>
            </StackPanel>
            <ListBox Grid.Row="1" Items="{Binding allSpots}" VirtualizationMode="Simple" Name="lb"  HorizontalAlignment="Left" >
              <ListBox.ItemTemplate>
                <DataTemplate>
                  <StackPanel Orientation="Horizontal">
                    <TextBlock Width="130" Text="{Binding time}"/>
                    <TextBlock Width="70" Text="{Binding frequency}"/>
                    <TextBlock Width="30" Text="{Binding snr}"/>
                    <TextBlock Width="30" Text="{Binding dt}"/>
                    <TextBlock Width="50" Text="{Binding mode}"/>
                    <TextBlock Width="50" Text="{Binding distance, Converter={x:Static p:StringConverters.StringFormat},ConverterParameter=\{0:0\}}" HorizontalAlignment="Right"/>

                      <Button Classes="LinkButton" Command="{Binding $parent[4].DataContext.SpotSelectedCommand}"
                       CommandParameter="{Binding}" >

                      <TextBlock Width="140" Text="{Binding msg}"
                        Foreground="{Binding color, Converter={x:Static r:Converters.SpotToColor}}"/>
                    </Button>
                  </StackPanel>
                </DataTemplate>
              </ListBox.ItemTemplate>
            </ListBox>
          </Grid>

        </TabItem>

is one of them

just put the name back in with the wrong case
Steven Kirk
@grokys
May 09 2018 11:40
This message was deleted
hmm yeah that should work
ahopper
@ahopper
May 09 2018 11:41

@RayyanTahir

 var bg = new ImageBrush(new Bitmap(AvaloniaLocator.Current.GetService<IAssetLoader>().Open(new Uri("resm:ControlCatalog.Assets.delicate-arch-896885_640.jpg"))));

works but there may be a much neater version

Rayyan Tahir
@RayyanTahir
May 09 2018 11:41
Thank you, that's neat enough for me :smile:
barbacelo
@barbacelo
May 09 2018 11:46
I wish i could use avalonia for my project but i dont think i can manage without a datagrid :(
ahopper
@ahopper
May 09 2018 11:51
@grokys I can access the #ftgrid.DataContext outside the itemscontrol but not inside
Steven Kirk
@grokys
May 09 2018 11:52
@barbacelo AvaloniaUI/Avalonia#1519 -- it's a WIP but hopefully on its way!
@ahopper any chance you could create a minimal repro and open an issue?
ahopper
@ahopper
May 09 2018 11:52
will do, cheers
@barbacelo the code i pasted above is me coping without a datagrid:)
barbacelo
@barbacelo
May 09 2018 11:59
I dont think i can cope without considering what i want to make would consist of multiple datagrids on each view
Rayyan Tahir
@RayyanTahir
May 09 2018 12:13
HorizontalOffset & VerticalOffset have no effect on Popup control. :(
ahopper
@ahopper
May 09 2018 12:32
I think they worked for me
Rayyan Tahir
@RayyanTahir
May 09 2018 12:33
Hmmm, I'll try to create a repro
ahopper
@ahopper
May 09 2018 12:35
just tested and they don't seem to work anymore
Rayyan Tahir
@RayyanTahir
May 09 2018 12:35
Can you please create an issue with your test repro?
ahopper
@ahopper
May 09 2018 12:37
I tested with my whole program, have you got something smaller
Rayyan Tahir
@RayyanTahir
May 09 2018 12:38
Nope, I'll create one now
walterlv
@walterlv
May 09 2018 13:35
@grokys A month has gone away, how about the Grid review?
Steven Kirk
@grokys
May 09 2018 13:35
hey @walterlv
walterlv
@walterlv
May 09 2018 13:35
(•̀ω•́)✧
Steven Kirk
@grokys
May 09 2018 13:35
sorry, are we ready for final review now?
@danwalmsley does the new grid seem to work ok with avalonstudio?
walterlv
@walterlv
May 09 2018 13:37
Sorry that I'm a little busy these days.
Steven Kirk
@grokys
May 09 2018 13:38
also @wieslawsoltes might you have time to try out #1517 with Core2D?
no problem - me too!
lets get this merged soon
Wiesław Šoltés
@wieslawsoltes
May 09 2018 13:38
Did not have time to test :worried:
Steven Kirk
@grokys
May 09 2018 13:38
it will be a huge improvement
danwalmsley
@danwalmsley
May 09 2018 13:44
@grokys I think it seems ok, theres quite a few bugs that have got into master is getting difficult to tell :(
i'll have another look at it shortly
Steven Kirk
@grokys
May 09 2018 13:45
hmm, maybe need to fix those first
danwalmsley
@danwalmsley
May 09 2018 13:45
the Portable.Xaml bug makes it really difficult to go back and check
I have to keep building the commits with the portable.xaml fix in
to see where bugs got introduced
the main issue is the property overhaul issue, but there is 1 or 2 more iv not had chance to investigate yet
Steven Kirk
@grokys
May 09 2018 13:47
hmm @walterlv sounds like we might have to fix some other bugs before we can properly test the new grid
will that be a problem?
walterlv
@walterlv
May 09 2018 13:50
No problem
Stano Turza
@Sorien
May 09 2018 13:59
im trying to implement Effects (DropShadowEffect and so on ) but im a bit confused with rendering part is there any way how to access Avalonia.Skia.DrawingContextImp from Avalonia.Media.DrawingContext?
Stano Turza
@Sorien
May 09 2018 14:07
PlatformImpl is Avalonia.Rendering.SceneGraph.DeferredDrawingContextImp + $exception {"Unable to cast object of type 'Avalonia.Rendering.SceneGraph.DeferredDrawingContextImpl' to type 'Avalonia.Skia.DrawingContextImpl'."} System.InvalidCastException
Steven Kirk
@grokys
May 09 2018 14:09
right, this is because it's using the deferred renderer so the DrawingContent impl isn't the actual platform renderer
the deferred drawing context draws to the scene graph
Benedikt Schroeder
@Gillibald
May 09 2018 14:49
If I knew how to test the new Grid on my local machine I would do it. Probably have to introduce a test application for real world scenarios.
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 15:28
@Sorien for implementing effects I'd suggest doing a Effect/EffectNode/EffectPlatformImpl set of classes/interfaces so you can add them into the scene graph and still have platform specific drawing.
Stano Turza
@Sorien
May 09 2018 15:33
@jkoritzinsky yep i'll try it that way
ahopper
@ahopper
May 09 2018 17:36
ItemsControl does not appear to render anything for anything in the Items collection that is null, is this expected?
Wiesław Šoltés
@wieslawsoltes
May 09 2018 17:53
@danwalmsley Playing a bit with drag and drop :smile: https://youtu.be/5BFVgKMZCVs
danwalmsley
@danwalmsley
May 09 2018 18:24
Nice
Can you drop stuff into an existing floating window?
William Humphreys
@WHumphreys
May 09 2018 18:52
Is it not time to do another small beta release? Ive seen a lot of changes on here since the last one. If you want this to be popular I say at least give people the latest version often even if some of it is flaky.
Especially as there has just been a large VS update and I notice Im now getting the waffly "Avelonia is slowing startup blah blah..."
Avalonia*
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 19:12
I'm up for a small beta release once we fix some of the flaky bugs we have since the property system change.
Wiesław Šoltés
@wieslawsoltes
May 09 2018 19:18
@danwalmsley Shure you can.
This is just my first quick attempt
Pretty simple stuff
My drag and drop code has evolved a lot last few days.
danwalmsley
@danwalmsley
May 09 2018 19:24
its not far off full docking now
im interested to know does the layout persist when you close and re-open the application?
Wiesław Šoltés
@wieslawsoltes
May 09 2018 19:24
Yes
I have layout serialized
Did not add this for windows
Still a lot to do
Benedikt Schroeder
@Gillibald
May 09 2018 19:42
A new beta release should include the reworked grid. It is used very often and the new implementation is just faster. Just my opinion. Grid layouts are everywhere. Is it possible to assign certain features to specific milestones? Bugfixes to current release are fine. Adding to much new in a short time makes it harder to release everything with confidence. Sure this is beta but a new release should not make anything worse.
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 19:44
That sounds good to me! Tbh we really need to get better at our release planning (and not naming our milestones specific releases when they'll likely get pushed back...)
danwalmsley
@danwalmsley
May 09 2018 19:49
@grokys iv made the requested changes to passwordchar implementation #1544
also with your stopping renderer on minimize did you see my comment, I think a simple change might be needed
man the PRs are stacking up
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 19:51
I'm graduating this weekend so I'll have a lot more time for Avalonia over the next few months so I can help with the PR load.
danwalmsley
@danwalmsley
May 09 2018 19:51
@jkoritzinsky congratulations :)
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 19:52
Thanks!
danwalmsley
@danwalmsley
May 09 2018 19:52
that will be a big celebration this weekend then?
@wieslawsoltes im wondering if we can capture your work into a standalone docking control we can share between avalonstudio and core2d?
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 19:53
Yep! Friday and Saturday with family and Sunday with friends!
danwalmsley
@danwalmsley
May 09 2018 19:53
then we can both help improve it
I might have a go at pulling out the relevant parts you have shown me
do you think its a good idea?
Steven Kirk
@grokys
May 09 2018 20:45
congratulations @jkoritzinsky !
Wiesław Šoltés
@wieslawsoltes
May 09 2018 20:47
@danwalmsley I am also interested into pulling it out into separate library
Steven Kirk
@grokys
May 09 2018 20:52
@danwalmsley when i try your repro branch for #1568 i'm getting an exception: Portable.Xaml.XamlObjectWriterException: 'GetObject is not allowed at current state Initial'
have you seen that? any idea why it's happening?
danwalmsley
@danwalmsley
May 09 2018 21:00
yeah I saw that
however i didn't think it was to do with the bug in question so i ignored it
that code works fine in avalonstudio without crashing,
so I assume iv made a mistake somewhere
in porting to repro
Steven Kirk
@grokys
May 09 2018 21:04
weird that whatever it is causes a xaml exception like that
danwalmsley
@danwalmsley
May 09 2018 21:04
I am assuming you only get that by clicking a tab right?
Steven Kirk
@grokys
May 09 2018 21:04
no, just running it
danwalmsley
@danwalmsley
May 09 2018 21:04
oh
i didn't see that
did you sync submodules?
Steven Kirk
@grokys
May 09 2018 21:05
yeah
danwalmsley
@danwalmsley
May 09 2018 21:05
because the portable XAML bug was giving me load of issues
hmm
i'll try here to see what happens
danwalmsley
@danwalmsley
May 09 2018 21:14
ok I'm seeing the same thing now
Steven Kirk
@grokys
May 09 2018 21:14
trying to work out what's causing it...
i don't know the xaml code so well though
danwalmsley
@danwalmsley
May 09 2018 21:14
i didn't get that the other day on my work machine
do you know which XAML file is causing the error?
its confusing because there is a UserControl called DocumentTabControl and an actual control of the same name
Steven Kirk
@grokys
May 09 2018 21:18
narrowed it down to:
            <DataTemplate>
                <cont:ViewModelViewHost IsVisible="{Binding IsVisible}" />
            </DataTemplate>
danwalmsley
@danwalmsley
May 09 2018 21:20
why would that be an issue?
Steven Kirk
@grokys
May 09 2018 21:21
no idea!
is that part important to repro #1568? could i still repro if i replace that with a textbox?
one bug at a time...
danwalmsley
@danwalmsley
May 09 2018 21:21
its not important for the issue
just put a textbox or something
Steven Kirk
@grokys
May 09 2018 21:22
runs if it do that, thanks
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 21:27
@grokys I'm working on the same bug. I'm trying to fix the Portable.Xaml issue because that's causing ControlCatalog to crash when trying to parse the ItemTemplate.
Steven Kirk
@grokys
May 09 2018 21:28
oh cool! i'm taking a look at the styling bug
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 21:29
I think they might be related. With a conditional breakpoint in the styling system I can somehow re-trigger the bug in template parsing that's causing the Portable.Xaml exception
danwalmsley
@danwalmsley
May 09 2018 22:03
@wieslawsoltes this might be a useful control for us ;)
dock-example.gif
probably we can place it inside the adorner layer, and make it shown when drag drop is over and has docking data in it
if the user is over the center one, we just do what you do now
and if its the others then we split into top and bottom or left and right and start a new set of tabs
Steven Kirk
@grokys
May 09 2018 22:09
ok so if i remove the :dockleft selector it works. looks like that pseudoclass isn't getting applied
danwalmsley
@danwalmsley
May 09 2018 22:14
@wieslawsoltes iv added a repo here: https://github.com/danwalmsley/AvaloniaDock and posted the code for the DockTarget control, just for prototyping
Steven Kirk
@grokys
May 09 2018 22:14
@danwalmsley :dockleft is only set as a pseudoclass on DocumentTabItem, but i can't find a control of that type in the app
danwalmsley
@danwalmsley
May 09 2018 22:14
is it in the controls folder?
Steven Kirk
@grokys
May 09 2018 22:15
i mean, i find the source for it, but i can't see where a control of that type is instantiated
danwalmsley
@danwalmsley
May 09 2018 22:15
erm let me see
it was a long time ago since I wrote this
it could be that they are never instantiated?
and perhaps previously it ignored the :dockleft and was working by mistake?
Steven Kirk
@grokys
May 09 2018 22:18
it looks like previously :dockleft was applied to every control in the app
danwalmsley
@danwalmsley
May 09 2018 22:19
wierd
Steven Kirk
@grokys
May 09 2018 22:19
so it looks like the properties overhaul might have fixed a bug you were relying on
danwalmsley
@danwalmsley
May 09 2018 22:20
ok i'll check that fixes it in the full AS
Steven Kirk
@grokys
May 09 2018 22:21
yeah check in the devtools if everything has :dockleft applied
actually
pseudoclasses defined by calling PseudoClass() are currently global
and Dock.Left is the default
so it looks like the problem might be with avalonia not applying that pseudoclass correctly
we should probably make it so that pseudoclasses created like that can only apply to a class and its subclasses
danwalmsley
@danwalmsley
May 09 2018 22:28
ok I will need to find the other bugs that got introduced into master
I think they were not part of the property overhaul though
Steven Kirk
@grokys
May 09 2018 22:33
ok, it seems that AvaloniaProperty.Initialized isn't getting called any more for objects on which the Dock property isn't explicitly defined
Jeremy Koritzinsky
@jkoritzinsky
May 09 2018 22:34
I fixed the Portable.Xaml exception. It's from the XAML in the template referring to a type that doesn't exist (ControlCatalog.Controls.ViewModelViewHost). I fixed the XAML namespacing to refer to the correct type and the exception goes away.
We really have to work with Portable.Xaml to get better error messages. It's getting way too hard to figure out what's a user error with their exceptions.
Steven Kirk
@grokys
May 09 2018 22:35
yeah definitely
@danwalmsley if you want a workaround for now, set :dockleft in the DocumentTabItem ctor
that should work until i fix this
danwalmsley
@danwalmsley
May 09 2018 22:36
@grokys ok this was the PR that introduced the other bugs
AvaloniaUI/Avalonia#1522
@grokys ok thanks
Steven Kirk
@grokys
May 09 2018 22:37
what bugs did that introduce?
@jkoritzinsky we also need to fix our xaml errors
is hiding the actual error message
it puts the error message in the inner exception, but we need to actually display it!
at the moment it just throws "Error loading xaml at blah" and hides the rest of the message
very unhelpful
we should be displaying "Blah blah occurred loading XAML at blah"
danwalmsley
@danwalmsley
May 09 2018 22:41
@grokys it also never tells you which XAML file errors are from, which would really help most of the time
Steven Kirk
@grokys
May 09 2018 22:41
yeah and that
danwalmsley
@danwalmsley
May 09 2018 22:41
@grokys the bug introduced does this for windows with HideSystemDecorations=True
image.png
weird space at top of window
and when maximized this happens
...
image.png
leaves a gap around the edge of window
I'll look into it
and if I can find a fix, ill test the new grid after that
Steven Kirk
@grokys
May 09 2018 22:45
that would be great. i kinda suck at win32
danwalmsley
@danwalmsley
May 09 2018 22:49
ok iv found it and understood it
its this
basically the new code keeps titlebar and just hides all the shit in it, maximize buttons, etc
i'll submit a PR to revert those lines
Steven Kirk
@grokys
May 09 2018 22:50
are those lines just not needed?
danwalmsley
@danwalmsley
May 09 2018 22:51
they are nothing to do with the canresize thing
I think it might have been an attempt to get Custom windows to understand can-resize property which usually call BeginResizeDrag themselves to start resize
but in that case they should probably check the value of CanResize
@commonguy might have some input
danwalmsley
@danwalmsley
May 09 2018 23:00
@grokys @jkoritzinsky there is a PR to restore that functionality, CanResize is unaffected.
AvaloniaUI/Avalonia#1574
danwalmsley
@danwalmsley
May 09 2018 23:12
@grokys properties overhaul has another bug too
Steven Kirk
@grokys
May 09 2018 23:12
@danwalmsley #1575
danwalmsley
@danwalmsley
May 09 2018 23:12
image.png
can you see the small caret there?
its not the right height
Steven Kirk
@grokys
May 09 2018 23:13
ah haha, yeah
danwalmsley
@danwalmsley
May 09 2018 23:13
that happens when I merge in the properties overhaul. iv no idea how that size gets set yet,
Steven Kirk
@grokys
May 09 2018 23:13
could that be fixed by #1575?
danwalmsley
@danwalmsley
May 09 2018 23:13
it also has the knock on effect that selections stop working
ok I'll see what that does
unfortunately no :(
Steven Kirk
@grokys
May 09 2018 23:16
heh well i could only hope
does it fix the previous problem?
danwalmsley
@danwalmsley
May 09 2018 23:19
it introduces more issues
image.png
can you see no text in the tab headers now
Steven Kirk
@grokys
May 09 2018 23:19
whaaaa?
well that's strange
danwalmsley
@danwalmsley
May 09 2018 23:20
hold on
it might have been caused by a typo
do you still have my repro open?
basically if you put a 'P' here
<Button.Styles>
              <Style Selector="Button">
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="Padding" Value="0"/>p
                <Setter Property="Margin" Value="0"/>
              </Style>
            </Button.Styles>
portable.xaml doesn't throw an exception
and it continues to run, but no text
I think I pressed ctrl + p and it got in there
false alarm
Steven Kirk
@grokys
May 09 2018 23:23
oh that's a bad bug in itself
but at least #1575 seems to work?
danwalmsley
@danwalmsley
May 09 2018 23:25
yes seems to work
I'm trying to find out more about the caret bug
Steven Kirk
@grokys
May 09 2018 23:29
ah but i've broken unit tests
yeah i see what i did there, d'oh
@danwalmsley if you could approve that PR, i'll merge when CI passes
Steven Kirk
@grokys
May 09 2018 23:41
merged
danwalmsley
@danwalmsley
May 09 2018 23:41
@grokys ok iv got a reasonably simpleish repro for the caret thing
do you have time to look at it now? If not i'll post to the issue
Steven Kirk
@grokys
May 09 2018 23:43
need to go to bed really, it's nearly 2am
depends how simple it is really
danwalmsley
@danwalmsley
May 09 2018 23:44
it might be simple it might not be
i'll post detailed instructions on how to repro
save it for tomorrow ;)
Steven Kirk
@grokys
May 09 2018 23:44
ok cool
danwalmsley
@danwalmsley
May 09 2018 23:44
it will require cloning Avaloniaedit,
but luckily its fairly obvious where the culprit is
so I don't think you will have to go stepping through avaloniaedit code too much
Textblock.FontSize property isn't getting set as it used to be
or inherited or something like that
danwalmsley
@danwalmsley
May 09 2018 23:50
ok #1576 details the issue and how to investigate it
shouldn't be too difficult after some sleep ;)