These are chat archives for AvaloniaUI/Avalonia

10th
May 2018
Jeremy Koritzinsky
@jkoritzinsky
May 10 2018 06:17
@grokys I was just messing with ControlCatalog on Linux and noticed a break. The CultureInfo property (along with its usage) on NumericUpDown causes ControlCatalog.NetCore to fail to start on .NET Core < 2.0.4 because of dotnet/corefx#24755.
Just a heads up. We might want to document that somewhere.
Nikita Tsukanov
@kekekeks
May 10 2018 08:44
@jkoritzinsky @grokys Are you going to update Portable.Xaml to the upstream version anytime soon? I kinda wanted to implement d:* properties based on the recent (well, it have been two months already) mc:Ignorable support
Steven Kirk
@grokys
May 10 2018 08:44
@kekekeks yeah i'd love to but we need cwensley/Portable.Xaml#94
Nikita Tsukanov
@kekekeks
May 10 2018 08:45
There are other differences in our fork, I think
Steven Kirk
@grokys
May 10 2018 08:45
yeah i thought there might be
any idea what these are? we should submit upstream PRs
Nikita Tsukanov
@kekekeks
May 10 2018 08:45
One is related to ICustomAttributeProvider
Steven Kirk
@grokys
May 10 2018 08:46
welcome back btw!
Nikita Tsukanov
@kekekeks
May 10 2018 08:46
It exists in netstandard2.0 but doesn't exist in netstandard1.3 which upstream is currently targeting
Steven Kirk
@grokys
May 10 2018 08:46
hmm yeah that one might be harder to get upstream
Nikita Tsukanov
@kekekeks
May 10 2018 08:47
We should be pushing for ditching netstandard1.3 support
Since UWP has had netstandard2.0 for half a year already
So there are no .NET platforms that don't support netstandard2.0
Steven Kirk
@grokys
May 10 2018 08:48
or at least a separate netstandard2.0 target
Nikita Tsukanov
@kekekeks
May 10 2018 08:48
That requires some type redirect magic
I've implemented it here
cwensley/Portable.Xaml#90
but @cwensley is not conveinced
Steven Kirk
@grokys
May 10 2018 08:49
hmm ok
Nikita Tsukanov
@kekekeks
May 10 2018 08:50
I've ported our changes related to multithreading cwensley/Portable.Xaml#87
So we are ok there
This is the list of the diffrencies except the recent changes (ambient provider and attached property fixes)
The part with xaml reader was fixed in a different way in the upstream
concurrentdictionary was merged
Steven Kirk
@grokys
May 10 2018 08:54
the whitespace part was fixed in a different way upstream i believe
Nikita Tsukanov
@kekekeks
May 10 2018 08:54
So we only need the ICustomAttributeProvider part
Other than that the upstream can be used as is
Rayyan Tahir
@RayyanTahir
May 10 2018 10:27
My avalonia application freezes when i'm frequently changing background colors of usercontrols in an itemscontrol on pointerenter/pointerleave events. It works fine if there are only 3-4 children, but gets stuck on a larger number
danwalmsley
@danwalmsley
May 10 2018 10:57
Do you have sample code?
Rayyan Tahir
@RayyanTahir
May 10 2018 11:05
Yeah, its a complete project that is hooked up to my production server
But, I'll try to create a repro
danwalmsley
@danwalmsley
May 10 2018 11:09
Is this to highlight items when you the mouse is over them?
If so why didn't you use style to do that?
Rayyan Tahir
@RayyanTahir
May 10 2018 11:11
Yes, I was trying to highlight only those that were not selected (which is stored in the view model), but didn't know if there was a datatrigger to take the viewmodel into account.
If one of them is selected it cannot be highlighted on pointerover. Here IsSelected is a property of my viewmodel which I'm not sure can be used in Avalonia style. in Wpf there is datatrigger that takes bindings, but no clue if there is a way in Avalonia
danwalmsley
@danwalmsley
May 10 2018 11:16
@RayyanTahir you can do this
Selector="Item:selected:pointerover"
and
Item:pointerover
that way you can make :selected and :selected:pointerover the same colour
and just :pointerover a different colour
would be nice if we supported
Rayyan Tahir
@RayyanTahir
May 10 2018 11:18
Since the child control that is selected is just a UserControl how will I tell the style that :selected needs to be binded with my viewmodel's IsSelected?
danwalmsley
@danwalmsley
May 10 2018 11:18
:selected!:pointerover
its in a SelectingItemsControl right?
Rayyan Tahir
@RayyanTahir
May 10 2018 11:19
Yeah that would surely be nice
No just ItemsControl is the parent container
danwalmsley
@danwalmsley
May 10 2018 11:19
change items control to SelectingItemsControl
Rayyan Tahir
@RayyanTahir
May 10 2018 11:19
Wow that is nice
danwalmsley
@danwalmsley
May 10 2018 11:19
that way :selected will be applied
Rayyan Tahir
@RayyanTahir
May 10 2018 11:19
I'll use that
Thanks :smile:
danwalmsley
@danwalmsley
May 10 2018 11:19
I think that should work for you
and hopefully your bug might go away (im assuming it must be related to that)
SelectingItemsControl has properties like SelectedItem and SelectedItems which you can bind to on your viewmodel
Rayyan Tahir
@RayyanTahir
May 10 2018 11:21
Basically when my application freezes (and it does for a long time), In Task Manager I see high cpu usage (38%-45%) on dotnet.exe process
danwalmsley
@danwalmsley
May 10 2018 11:21
which you may find useful
@RayyanTahir did you bind Items to IEnumerable or ObservableCollection?
Rayyan Tahir
@RayyanTahir
May 10 2018 11:21
To IDerivedReactiveList
danwalmsley
@danwalmsley
May 10 2018 11:21
also check that your items control is inside something that has a fixed height
if you place things like listbox or itemscontrol inside a scrollviewer for example
Rayyan Tahir
@RayyanTahir
May 10 2018 11:22
Yes its in a ScrollViewer with fixed height
Let me paste my code here
danwalmsley
@danwalmsley
May 10 2018 11:22
then they get unlimited height and virtualization doesn't work
since it tries to generate everysingle element
does you memory usage rapidly increase during the freeze?
Rayyan Tahir
@RayyanTahir
May 10 2018 11:23
Yes that does increase too
<ScrollViewer Margin="0,-5,0,0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Height="500">
      <ItemsControl Name="ItemsControl">
        <ItemsControl.ItemTemplate>
          <DataTemplate>
            <local:SwapTeamItem HorizontalAlignment="Left" TeamId="{Binding Id}"/>
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>
    </ScrollViewer>
danwalmsley
@danwalmsley
May 10 2018 11:24
I think that's the issue
your scrollviewer has a fixed height
but the content inside it is unlimited height
Rayyan Tahir
@RayyanTahir
May 10 2018 11:24
Yes, because now I recall that SystemOutOfMemoryException is related to this
You mean each individual child is scalable or has variable height?
danwalmsley
@danwalmsley
May 10 2018 11:25
can you use ListBox? which has its own scrollviewer?
Rayyan Tahir
@RayyanTahir
May 10 2018 11:25
Yes that could work too
danwalmsley
@danwalmsley
May 10 2018 11:25
I mean that your scrollviewer or the viewport that is visible is 500
but the content is actually the height of all the items in the list visible or not
Listbox comes with virtualization support out the box
see my intellisense control (which suffered the same issue) here...
vistualization is enabled by default meaning it will only generate controls for the ones visible on the screen
it will work a lot better for you
ListBox inherits SelectingItemsControl anyway
Rayyan Tahir
@RayyanTahir
May 10 2018 11:28
Yes, that would be better, because yes there are items in the ItemsControl that are not visible
danwalmsley
@danwalmsley
May 10 2018 11:28
and if you want it to layout in a different way you can change its ItemsPanel like here
then the sky is the limit
Rayyan Tahir
@RayyanTahir
May 10 2018 11:29
Haha, I'll go for this. Thanks man!
danwalmsley
@danwalmsley
May 10 2018 11:29
and you maintain all the virtualization, scrolling, and selecting that listbox provides :)
no problem
Nikita Tsukanov
@kekekeks
May 10 2018 12:40
I think it could be done with ItemsControl with ItemsPanel set to VirtualizingStackPanel
No need for ListBox
Rayyan Tahir
@RayyanTahir
May 10 2018 12:40
Thank you @kekekeks I'll check this and get back to you
zii-dmg
@zii-dmg
May 10 2018 12:41
Maybe incorrect HRESULT marshaling: AvaloniaUI/Avalonia#1577
Nikita Tsukanov
@kekekeks
May 10 2018 12:42
HRESULT is definitely an 32-bit integer
it shouldn't be defined as long
Rayyan Tahir
@RayyanTahir
May 10 2018 12:44
@kekekeks I tried your solution i.e VirtualizingStackPanel inside ItemsControl.ItemsPanel but that too led me to a memory leak issue mentioned earlier
Besides that, ListBox gives me built-in scrolling, virtualization and selection capability and that too without memory leak as @danwalmsley mentioned, so I think that would be a better solution for my problem.
danwalmsley
@danwalmsley
May 10 2018 12:47
@kekekeks main reason for listbox or at least SelectingItemsPanel was he need :selected classes applied for styling
you cant ever put VirtualizingStackPanel inside a scrollviewer unfortunately
it defeats the point of virtualization
@kekekeks do you have any comment for my PR on modal windows, and the remaining issue I'm having with it from you knowledge of win32?
danwalmsley
@danwalmsley
May 10 2018 12:53
AvaloniaUI/Avalonia#1542
Nikita Tsukanov
@kekekeks
May 10 2018 12:54
Ehm, actually VirtualizingStackPanel is used by textbox

@danwalmsley

You must not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function.

Rayyan Tahir
@RayyanTahir
May 10 2018 12:58
@danwalmsley the following style applied to the child usercontrol of Listbox doesn't render black background on just :pointerover on an unselected item. Am I missing something?
<Style x:Key="a" Selector="UserControl.ListItem:selected">
      <Setter Property="Background">
        <Setter.Value>
          <ImageBrush Source="resm:OneScreenSwap.Assets.selected-blue-bg.png"/>
        </Setter.Value>
      </Setter>
    </Style>
    <Style x:Key="b" Selector="UserControl.ListItem:selected:pointerover">
      <Setter Property="Background">
        <Setter.Value>
          <ImageBrush Source="resm:OneScreenSwap.Assets.selected-blue-bg.png"/>
        </Setter.Value>
      </Setter>
    </Style>
    <Style x:Key="c" Selector="UserControl.ListItem:pointerover">
      <Setter Property="Background" Value="Black"/>
    </Style>
danwalmsley
@danwalmsley
May 10 2018 12:59
@kekekeks I don't want to set the parent I want to set the owner
ownership and parenting are different
I started off setting the Parent, but the child window ends up like a MDI window and cant be moved outside the parent
Nikita Tsukanov
@kekekeks
May 10 2018 13:00
-8 is GWL_HWNDPARENT
danwalmsley
@danwalmsley
May 10 2018 13:00
if you call setparent it has a different effect let me find docs
SetParent works differently for WS_OVERLAPPED, WS_CHILD and WS_POPUP
danwalmsley
@danwalmsley
May 10 2018 13:01
this is what I'm trying to implement
danwalmsley
@danwalmsley
May 10 2018 13:03
@kekekeks seems that GWL_HWNDPARENT is msft sloppy naming
Nikita Tsukanov
@kekekeks
May 10 2018 13:03
It's the SAME thing
You specify hWndParent in CreateWindowEx call
both for overlapped and child windows
danwalmsley
@danwalmsley
May 10 2018 13:04
see the stackoverflow
Nikita Tsukanov
@kekekeks
May 10 2018 13:04
See the docs from MSDN
danwalmsley
@danwalmsley
May 10 2018 13:04
SetWindowLong(handle, GWL_HWNDPARENT, foo); This actually sets the window's owner, not the parent - despite the GWL_HWNDPARENT being used. Are the terms parent/owner interchangeable, or is there actually a difference?
Nikita Tsukanov
@kekekeks
May 10 2018 13:04
"Owned windows" section
Docs also expicitly state that you shouldn't pass GWL_HWNDPARENT to SetWindowLong
danwalmsley
@danwalmsley
May 10 2018 13:05
 owner's window handle as the hwndParent parameter of CreateWindowEx
ok so here they have the terminology wrong again
ok I did want to do it that way before
but currently our window class calls CreateWindowEx from the contructor
so by then its too early I think to know the parent window
?
but perhaps we could call CreateWindowEx when Show is called first time?
@RayyanTahir what happens if you only have the pointer over one, does it work?
@kekekeks You must not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function.
Rayyan Tahir
@RayyanTahir
May 10 2018 13:10
The last style that only has :pointerover was added to check for unselected state and pointer over right? But no effect happens
danwalmsley
@danwalmsley
May 10 2018 13:10
we are not calling it on a child window, so I'm not sure if that applies here
it looks right
but if you comment out the other 2 does it work?
Rayyan Tahir
@RayyanTahir
May 10 2018 13:10
checking
danwalmsley
@danwalmsley
May 10 2018 13:12
@kekekeks i.e. in this case we are calling it on a window that is currently not a child, so its not changing it, the docs leave a lot of abiguity
I wonder how wpf manages this
they are doing the same thing I did
Nikita Tsukanov
@kekekeks
May 10 2018 13:14
It seems that GTK is using SetWindowLongPtr
BTW, you should use gtk_window_set_transient_for for GTK backend
danwalmsley
@danwalmsley
May 10 2018 13:15
ok
This changes the *owner* of the window, despite the misleading

   * name. (Owner and parent are unrelated concepts.) At least that's

   * what people who seem to know what they talk about say on

   * USENET. Search on Google.
nice comment there in the gtk code :)
ok so I think the issue I'm having isn't related to calling that method
basically you minimize and window gets cleared
Rayyan Tahir
@RayyanTahir
May 10 2018 13:23
@danwalmsley the :selected pseudoclass isn't working either. And just the :pointerover won't work.
danwalmsley
@danwalmsley
May 10 2018 13:24
you don't need UserControl.ListItem I don't think
just ListItem
Rayyan Tahir
@RayyanTahir
May 10 2018 13:24
ok
danwalmsley
@danwalmsley
May 10 2018 13:25
can you open the DevTools
F12
and pointerover an item in the list and do a print screen
CTRL + SHIFT over an item to automatically expand the logical tree
Rayyan Tahir
@RayyanTahir
May 10 2018 13:25
sure one sec
If I remove UserControl then I get: 'Could not convert object 'Background' (of type System.String) to {clr-namespace:Avalonia;assembly=Avalonia.Base}AvaloniaProperty: Could not determine the target type. Please fully qualify the property name.'
danwalmsley
@danwalmsley
May 10 2018 13:28
ok try a selector like this
<Style Selector="UserControl.ListBox /template/ ListBoxItem:pointerover">
does that work?
Rayyan Tahir
@RayyanTahir
May 10 2018 13:28
Checking
danwalmsley
@danwalmsley
May 10 2018 13:29
also here
is how listbox styles itself so a selector like this would probably be better for you
Selector="ListBoxItem:pointerover /template/ ContentPresenter"
that I think will work
and Setter Background
sometimes the styling isn't so intuitive once you have to /template/ it
but thankfully you can easily look at the source code of inbuilt theme to find out
Rayyan Tahir
@RayyanTahir
May 10 2018 13:31
Right, Selector="UserControl.ListBox /template/ ListBoxItem:pointerover" didn't work, trying the one with ContentPresenter
danwalmsley
@danwalmsley
May 10 2018 13:31
contentpresenter must work
don't put user control in there
Rayyan Tahir
@RayyanTahir
May 10 2018 13:32
Yup that works
Thanks :)
danwalmsley
@danwalmsley
May 10 2018 13:32
we got there in the end!
Rayyan Tahir
@RayyanTahir
May 10 2018 13:33
Thanks to you!
Btw the last style with just :pointerover does bring black background over a selected item. Meaning that it doesn't assume the negative effect of :selected
I'll share my updated styles here again
<Style x:Key="lsi" Selector="ListBoxItem /template/ ContentPresenter">
      <Setter Property="Background" Value="Transparent"/>
    </Style>
    <Style x:Key="lsa" Selector="ListBoxItem:selected /template/ ContentPresenter">
      <Setter Property="Background">
        <Setter.Value>
          <ImageBrush Source="resm:OneScreenSwap.Assets.selected-blue-bg.png"/>
        </Setter.Value>
      </Setter>
    </Style>
    <Style x:Key="lsb" Selector="ListBoxItem:selected:pointerover /template/ ContentPresenter">
      <Setter Property="Background">
        <Setter.Value>
          <ImageBrush Source="resm:OneScreenSwap.Assets.selected-blue-bg.png"/>
        </Setter.Value>
      </Setter>
    </Style>
    <Style x:Key="lsc" Selector="ListBoxItem:pointerover /template/ ContentPresenter">
      <Setter Property="Background" Value="Black"/>
    </Style>
Benedikt Schroeder
@Gillibald
May 10 2018 13:54
Is there a reason window has no ResizeMode property? Wouldnt that be better instead of having a CanResize property? We should probably track CanResize support for other platforms window implementation. The PR that introduced CanResize support only supports Win32 as far as i know.
danwalmsley
@danwalmsley
May 10 2018 14:12
I don't think so
danwalmsley
@danwalmsley
May 10 2018 14:21
as in I don't think there is a reason I couldn't be done
Rayyan Tahir
@RayyanTahir
May 10 2018 14:47
Do we have a pseudoclass :orientationhorizontalor :orientationvertical for ScrollBar ?
I basically want to set styles based on orientation of ScrollBar
Rayyan Tahir
@RayyanTahir
May 10 2018 14:57
<Setter Property="Width" Value="Auto"/> gives me Auto is not a valid value for Double
* won't work either for ScrollBar
Steven Kirk
@grokys
May 10 2018 15:32
@RayyanTahir yes there are :horizontal and :vertical pseudoclasses: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Default/ScrollBar.xaml#L51
@Gillibald CanResize vs ResizeMode is discussed in the related issue AvaloniaUI/Avalonia#437
Sorien
@Sorien
May 10 2018 15:43
OT: template selector looks weird, still thinks that css way would be somethink like ScrollBar:template(RepeatButton.repeattrack) rather than ScrollBar /template/ RepeatButton.repeattrack /template/ looks like comment /template/ ;)
/*template*/
Rayyan Tahir
@RayyanTahir
May 10 2018 15:47
I'm trying to make the gray-area behind Thumb of scrollbar transparent. Where can I set this? See image below for reference
scrollbar.PNG
I copied default theme styles of scrollviewer, scrollbar and repeatbutton
Rayyan Tahir
@RayyanTahir
May 10 2018 15:51
That didn't work
ahopper
@ahopper
May 10 2018 19:06
I have a vague recollection of someone here producing some wpf to avalonia view conversion tool , is this a figment of my imagination or does it exist? If not has anyone got any thoughts on producing one?
Jeremy Koritzinsky
@jkoritzinsky
May 10 2018 19:08
There's the AvaloniaAnalyzers project that has converters for DependencyPropertys and some control types. It should still work.
ahopper
@ahopper
May 10 2018 19:10
I'll have a look, simple stuff like replacing labels with textblocks and stripping properties that don't exist would be a time saver
I've probably spent most typing time on replacing textformat with a converter
ahopper
@ahopper
May 10 2018 19:21
I've come to realize that good design time data is very handy in doing a conversion as catching the rather terse xaml errors at runtime is a slow process!
Vsevolod Pilipenko
@Karnah
May 10 2018 19:29
Hello, friends. I have a problem with TextBox, AllignmentProperty. Please, open sample application, go to TextBoxView and try select one word in "Center aligned text" and "Right aligned text". Did you know about this problem?
Jeremy Koritzinsky
@jkoritzinsky
May 10 2018 19:32
@Karnah Is that on master or 0.6.1?
Cause I'm pretty sure that's fixed in master
Vsevolod Pilipenko
@Karnah
May 10 2018 19:51
@jkoritzinsky, on master
Commit bc3d6ec8
Снимок.JPG
Jeremy Koritzinsky
@jkoritzinsky
May 10 2018 19:55
Looks like #1448 broke again. Can you file another bug and mention it's still present in bc3d6ec8?
Vsevolod Pilipenko
@Karnah
May 10 2018 20:07
Yes, sure, thanks
danwalmsley
@danwalmsley
May 10 2018 20:07
@RayyanTahir I think this is setting the scrollbar background
have you tried setting ScrollBar.Background?
Vsevolod Pilipenko
@Karnah
May 10 2018 20:14
@jkoritzinsky i left comment in #1448. Or i'll need create new issue?
danwalmsley
@danwalmsley
May 10 2018 20:15
@Karnah I think it might be same as #1527?
if you think it is please add further information to that issue
otherwise open a separate one
I think they are slightly different issues actually
so iv reopend #1448
Vsevolod Pilipenko
@Karnah
May 10 2018 20:24
@danwalmsley, thanks!
Sorry, i am falling asleep. I'll create PR with my way tomorrow. But it seems to me, this is not a solution
Steven Kirk
@grokys
May 10 2018 21:26
@Sorien /template/ came from /deep in CSS, which has since been removed anyway
i think it was replaced in CSS with >>> which i do prefer
we should probably do the same (add >>> and deprecate /template/)
Jeremy Koritzinsky
@jkoritzinsky
May 10 2018 22:29
I like that syntax!