These are chat archives for AvaloniaUI/Avalonia

19th
Apr 2018
Steven Kirk
@grokys
Apr 19 2018 04:27
@danwalmsley not sure. sounds like it should be possible. what isn't working?
ahopper
@ahopper
Apr 19 2018 06:42
I've been playing with styles and think they are great. Is there a way to apply a style to a group of controls but prevent it propagating to some children ie I want all toolbar toggleButtons to be the same but don't want it to apply to the toggleButton in a dropdown in the toolbar.
danwalmsley
@danwalmsley
Apr 19 2018 06:43
It sure is
Give me a second I'll do an example
ahopper
@ahopper
Apr 19 2018 06:45
thanks, the buttons are not all at the same level in the tree( some in nested stackpanels)
danwalmsley
@danwalmsley
Apr 19 2018 06:47
do you have a little sample xaml for your scenario?
ahopper
@ahopper
Apr 19 2018 06:48
give me a few mins. I really like the idea of somewhere to put small examples and snippets.
ill add an example here for this
just post your current xaml your want to style here in the chat
ahopper
@ahopper
Apr 19 2018 06:58
 <StackPanel Classes="toolbar" Orientation="Horizontal">
    <ToggleButton>a</ToggleButton>
    <StackPanel Orientation="Horizontal" IsVisible="{Binding extrafeatures}">
      <ToggleButton>b</ToggleButton>
      <ToggleButton>c</ToggleButton>
      <DropDown>
        <DropDownItem>1</DropDownItem>
        <DropDownItem>2</DropDownItem>
      </DropDown>
    </StackPanel>
  </StackPanel>
danwalmsley
@danwalmsley
Apr 19 2018 06:59
ok
so not style ToggleButtons inside DropDownItems?
ahopper
@ahopper
Apr 19 2018 07:00
yep
the one that makes the dropdown open
danwalmsley
@danwalmsley
Apr 19 2018 07:00
what are you setting with the style?
just so my example does the same
ahopper
@ahopper
Apr 19 2018 07:02
<Style Selector="ToggleButton.toolbar">
        <Setter Property="Margin" Value="12,3,12,3"></Setter>
        <Setter Property="Width" Value="50"></Setter>
        <Setter Property="Height" Value="50"></Setter>
       <Setter Property="BorderThickness" Value="0"></Setter>
        <Setter Property="Background" Value="Transparent"></Setter>
      </Style>
the real code has more nesting but is full of custom controls
danwalmsley
@danwalmsley
Apr 19 2018 07:05
why do you use 2 stackpanels here?
ahopper
@ahopper
Apr 19 2018 07:06
as an easy way to hide a block of controls, the real code has some usercontrols that also go in the toollbar and contain buttons
danwalmsley
@danwalmsley
Apr 19 2018 07:07
so basically the toggle buttons inside both stackpanels should be selected?
you can do this
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="StyleByClass">
  <Window.Styles>
    <Style Selector="StackPanel > ToggleButton">
      <Setter Property="Foreground" Value="Red"/>
    </Style>
  </Window.Styles>
     <StackPanel Classes="toolbar" Orientation="Horizontal">
    <ToggleButton>a</ToggleButton>
    <StackPanel Orientation="Horizontal" IsVisible="{Binding extrafeatures}">
      <ToggleButton>b</ToggleButton>
      <ToggleButton>c</ToggleButton>
      <DropDown>
        <DropDownItem>
          <ToggleButton>1</ToggleButton>
        </DropDownItem>
        <DropDownItem>
          <ToggleButton>2</ToggleButton>
        </DropDownItem>
      </DropDown>
    </StackPanel>
  </StackPanel>
</Window>
any child that is a direct decendent of StackPanel will get the style
btw when you type a tag and there is nothing in the tag...
i.e.
Steven Kirk
@grokys
Apr 19 2018 07:10
yep, what dan said. in addition it might be a good idea to add a class to the StackPanel to say "toggle buttons below this point are different"
danwalmsley
@danwalmsley
Apr 19 2018 07:10
<Setter Property="Background" Value="Transparent"></Setter>
you can better write
<Setter Property="Margin" Value="12,3,12,3" />
Steven Kirk
@grokys
Apr 19 2018 07:11
    <Style Selector="StackPanel.specialToggleButtons > ToggleButton">
      <Setter Property="Foreground" Value="Red"/>
    </Style>
<StackPanel Classes="specialToggleButtons" Orientation="Horizontal" IsVisible="{Binding extrafeatures}">
danwalmsley
@danwalmsley
Apr 19 2018 07:12
@grokys that selector can be simplified to .specialToggleButtons > ToggleButton
in case you changed to a DockPanel
Steven Kirk
@grokys
Apr 19 2018 07:13
yes though for performance reasons it's better to put a class name on selectors if it's always going to apply to a particular type
danwalmsley
@danwalmsley
Apr 19 2018 07:13
or 2 different controls
ahopper
@ahopper
Apr 19 2018 07:13
I was really wondering if there was a way without having to know all possible containing types but guess this is not logically possible
danwalmsley
@danwalmsley
Apr 19 2018 07:13
ah ok
@grokys is there a equivalent of css not
Steven Kirk
@grokys
Apr 19 2018 07:13
if you don't know the containing type just do as dan said and use .specialToggleButtons > ToggleButton
danwalmsley
@danwalmsley
Apr 19 2018 07:14
so you could do !.sepecialToggleButtons
Steven Kirk
@grokys
Apr 19 2018 07:14
not currently no
danwalmsley
@danwalmsley
Apr 19 2018 07:14
ok
Steven Kirk
@grokys
Apr 19 2018 07:14
would def be useful
ahopper
@ahopper
Apr 19 2018 07:15
is there a way to prevent the style applying to the dropdown
danwalmsley
@danwalmsley
Apr 19 2018 07:15
.specialToggleButtons > ToggleButton
wont apply to dropdown
ahopper
@ahopper
Apr 19 2018 07:17
but it can't simply be put at the top level of the toolbar
ahopper
@ahopper
Apr 19 2018 07:27
I like the idea of a ! I think that would be very useful to prevent styles propagating further than you want
Steven Kirk
@grokys
Apr 19 2018 07:33
is that how you'd do it in CSS?
(in CSS i think the operator is :not())
ahopper
@ahopper
Apr 19 2018 07:38
I guess so, being easily able to protect things like dropdowns and datepicker from unexpected effect of loosely applied styles would be nice, but I'm probably just being lazy
danwalmsley
@danwalmsley
Apr 19 2018 07:43
i think that will definately be added in future
for now your only option is to add a class
ahopper
@ahopper
Apr 19 2018 07:44
Great and thanks for all the help, it is much appriciated
Benedikt Schroeder
@Gillibald
Apr 19 2018 07:52
I
ahopper
@ahopper
Apr 19 2018 08:14
how about being able to cancel a style in the Classes property?
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 12:43
Searching for {Binding in/src/Core2D.Avaloniacase sensitive (Found 911 matches in 62 files) :)
@jmacato Almost finished converting commands to use methods in Core2D
Jumar Macato
@jmacato
Apr 19 2018 12:45
@wieslawsoltes can't wait for another coreRT build :D
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 12:46
I have added also CoreRT builds to CI server https://ci.appveyor.com/project/wieslawsoltes/core2d/build/2026
Jumar Macato
@jmacato
Apr 19 2018 12:46
neat :D
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 12:47
Publish-NetCoreRT 00:05:44.5088044
It takes a lot of time
Jumar Macato
@jmacato
Apr 19 2018 12:48
i'll give it a shot here in linux
which branch should i checkout?
Jumar Macato
@jmacato
Apr 19 2018 12:48
thanks
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 12:48
I had few xaml typos so it may still crush
But main window shows, the editor may or may not
Waiting for build to finish...
Jumar Macato
@jmacato
Apr 19 2018 12:49
okay, i'll wait for that build first
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 12:49
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 12:57
Ach
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by
has been thrown by the target of an invocation. ---> Portable.Xaml.XamlObjectWriterException: An error occured getting provided value ---> System.Reflection.MissingMetadataException: 'Core2D.Style.LineCap[]' is missing metadata. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=392859
Need to add more types to rd.xml :worried:
Jumar Macato
@jmacato
Apr 19 2018 12:57
missing types again
so tedious
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 12:58
This one is annoying , I have added full assembly, but still complains
Will do this later
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 14:59
@jmacato Managed to get more stuff working with Core2D
Jumar Macato
@jmacato
Apr 19 2018 15:00
@wieslawsoltes great! you solved the missing type?
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 15:00
yes that was easy part
Still its hangs on some task
Core2D working (mostly) in release mode using latest CoreRT runtime :smile:
Jumar Macato
@jmacato
Apr 19 2018 15:05
i'm currently trying it out now
on linux CoreRT
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 15:06
I think GC.Collect(); in my project unload may be the issue :fire:
Jumar Macato
@jmacato
Apr 19 2018 15:08
what param should i pass in dotnet publish to enable corert build?
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 15:08
dotnet publish src/Core2D.Avalonia/Core2D.Avalonia.csproj -c Release -r win-x64 -o bin/win-x64-release -v m /p:CoreRT=True
Jumar Macato
@jmacato
Apr 19 2018 15:09
okay thanks
Jumar Macato
@jmacato
Apr 19 2018 15:24
yup no good here, they havent built a new nuget package @ corert
Wiesław Šoltés
@wieslawsoltes
Apr 19 2018 15:25
for linux?
Jumar Macato
@jmacato
Apr 19 2018 15:25
yep