These are chat archives for AvaloniaUI/Avalonia

13th
Dec 2018
BenLampson(赵元源)
@BenLampson
Dec 13 2018 03:55
There's no control like the messagebox?
I saw the dialog in Youtube video.. But I can't find that in the project or in the Namespace Axxxx.constrols~~~
SunTai(三台)
@a44281071
Dec 13 2018 07:16
can i publish linux-arm to raspberryPI3 by netcore2.1?
ahopper
@ahopper
Dec 13 2018 07:19
@BenLampson you create a Window with your dialog content in and call ShowDialog on it, alternatively you can use a popup
Nikita Tsukanov
@kekekeks
Dec 13 2018 07:35
@a44281071 You need to build SkiaSharp for ARM
SunTai(三台)
@a44281071
Dec 13 2018 07:36
any build work documents? about pi3(armv7) and android? thanks!
Luis von der Eltz
@toytonics
Dec 13 2018 12:51
Hi, Are there any plans to implement TargetNullValue for Bindings?
Wiesław Šoltés
@wieslawsoltes
Dec 13 2018 13:00
I have partially integrated open-source version of System.Xaml https://github.com/wieslawsoltes/Avalonia/tree/OpenSourceSystemXaml it needs more work if anyone is interested :smile: it uses my forked version https://github.com/wieslawsoltes/wpf/tree/87a1e3153143b5d3910f8993ecb318b013099223
Steven Kirk
@grokys
Dec 13 2018 13:27
@toytonics yes that's been requested before, we should add it
@wieslawsoltes did you see my system-xaml branch?
i did some work on that a few months ago
Luis von der Eltz
@toytonics
Dec 13 2018 13:28
for now I guess !!PropertyThatMayNull does the trick for converting null to bool at least :)
Wiesław Šoltés
@wieslawsoltes
Dec 13 2018 13:38
@grokys I did but did not check the code :smile: this was just quick hack on my side :fire:
did you get it compiling and working ?
the performance of open-source System.Xaml is not that great compared to Portable.Xaml anyway
danwalmsley
@danwalmsley
Dec 13 2018 13:49
@wieslawsoltes if your using netcore3.0 I saw one of the dotnet team tweet that performance isn't good on .net core 3.0 yet because they haven't ngened the assemblies
could that be reason for performance comparison?
Nikita Tsukanov
@kekekeks
Dec 13 2018 13:51
Portable.Xaml isn't ngened either
Wiesław Šoltés
@wieslawsoltes
Dec 13 2018 13:55
The comparison was done using same conditions and both libraries have not been ngened https://github.com/wieslawsoltes/Portable.Xaml/tree/SystemXamlOpenSourceBenchmark/src/Portable.Xaml.Benchmark
Nikita Tsukanov
@kekekeks
Dec 13 2018 13:56
The reason for using System.Xaml
Would be human-readable error messages
danwalmsley
@danwalmsley
Dec 13 2018 13:58
once we go to code generation then performance wont be too much of an issue anyway
@kekekeks system.xaml might have advantages in designer land too?
like knowing what line of code a control in the ui is declared on?
Steven Kirk
@grokys
Dec 13 2018 13:59
portable.xaml still has a lot of bugs and missing functionality unfortunately
i'd prefer to move to system.xaml and try to improve its performance
also the portable.xaml codebase isn't very pleasant
Nikita Tsukanov
@kekekeks
Dec 13 2018 14:56

system.xaml might have advantages in designer land too

Honestly, no idea

From what I've seen in the code of SharpDevelop's designer, they are parsing xaml manually
well, not entirely manually
But definitely not in the same way as WPF does
Joshua Davis
@a11smiles
Dec 13 2018 16:33

how would I do this in Avalonia:

<ListBox BorderThickness="0" HorizontalAlignment="Stretch"  >
    <ListBox.Resources>
        <Style TargetType="ListBoxItem">
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
            </Style.Resources>
        </Style>
    </ListBox.Resources>                
</ListBox>

"TargetType" isn't a valid property on Style

Benedikt Schroeder
@Gillibald
Dec 13 2018 16:43
@a11smiles Avalonia Styles have a Selector
Joshua Davis
@a11smiles
Dec 13 2018 16:50

@Gillibald thanks, I found the Selector attribute after I posted, but couldn't get it to work until I realized it behaved closer to a CSS selector.

general question, I see the benefit of the Selector...pretty cool. But is there a reason why Avalonia isn't also implementing WPF's traditional attributes like TargetType? I think it would make the transition and adoption easier.

cbstryker
@cbstryker
Dec 13 2018 16:53
I hope this is the right place to ask, but I'm new to Avalonia and have decided to give it a go. I installed the extension for VS and the templates. I created a new Avalonia project and when I try to build it I get a "System.IO.FileNotFoundException: 'Unable to find view for Test.App"', I likely have something misconfigured, but I cannot figure out what. Anyone have any ideas?
Joshua Davis
@a11smiles
Dec 13 2018 17:34

guys, sorry about the questions that may seem basic, but I'm trying to figure out the "translation" into Avalonia. I'm trying to bind a non-observable list to a ListBox. But, I can't get items to show.

ViewModel:

        public List<Models.User> users = new List<Models.User>() {
            new Models.User() { FirstName = "John", LastName = "Doe" },
            new Models.User() { FirstName = "Jane", LastName = "Doe" }
        };

View:

<ListBox DataContext="{Binding users}" Grid.Column="0" Grid.Row="0" Background="Transparent" Foreground="White" BorderThickness="0" HorizontalAlignment="Stretch">
            <ListBox.Styles>
                <Style Selector="ListBoxItem">
                    <Setter Property="Padding" Value="5"/>
                </Style>
                <Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
                    <Setter Property="Background" Value="Red"/>
                </Style>
            </ListBox.Styles>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding FirstName}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

I've tried DataContext and Items, but I cannot get any items to show.

Wiesław Šoltés
@wieslawsoltes
Dec 13 2018 17:44
<ListBox Items="{Binding users}"
Joshua Davis
@a11smiles
Dec 13 2018 17:44
@wieslawsoltes I've tried that, nothing shows
Wiesław Šoltés
@wieslawsoltes
Dec 13 2018 17:44
public List<Models.User> users { get; set; }
users = new List<Models.User>() {
            new Models.User() { FirstName = "John", LastName = "Doe" },
            new Models.User() { FirstName = "Jane", LastName = "Doe" }
        };
thid.DataContext = this;
Joshua Davis
@a11smiles
Dec 13 2018 18:01

so, I've got another issue, not sure why...

when I run the app, the chrome launches, but the window contents don't actually appear until I move my mouse over the window. It's just a blank window/chrome with the background. Here's my MainWindow.xaml view code:

<Window xmlns="https://github.com/avaloniaui" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:vm="clr-namespace:avTest.ViewModels;assembly=avTest" Icon="resm:avTest.Assets.avalonia-logo.ico" Title="Users" Width="800" Height="600" FontFamily="Segoe UI, Lucida Grande, Ubuntu" FontSize="14">
    <Window.Background>
        <SolidColorBrush Color="#181818"/>
    </Window.Background>
    <Design.DataContext>
        <vm:MainWindowViewModel/>
    </Design.DataContext>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="3*" MinWidth="325" />
            <ColumnDefinition Width="7*" />
        </Grid.ColumnDefinitions>
        <Rectangle Grid.Column="0" Grid.RowSpan="1">
            <Rectangle.Fill>
                <SolidColorBrush Color="#232323"/>
            </Rectangle.Fill>
        </Rectangle>

        <ListBox Items="{Binding users}" Grid.Column="0" Grid.Row="0" Background="Transparent" Foreground="White" BorderThickness="0" HorizontalAlignment="Stretch">
            <ListBox.Styles>
                <Style Selector="ListBoxItem">
                    <Setter Property="Padding" Value="5"/>
                </Style>
                <Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
                    <Setter Property="Background" Value="Red"/>
                </Style>
            </ListBox.Styles>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding FirstName}" />
                    <TextBlock Text="{Binding LastName}" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>


</Window>
as soon I move my mouse over the app, everything appears
Joshua Davis
@a11smiles
Dec 13 2018 18:13
I'm on a Mac and using VS Code by the way
Nikita Tsukanov
@kekekeks
Dec 13 2018 18:16
Might be somehow related to our mac backend
Are you using the nightly build?
Joshua Davis
@a11smiles
Dec 13 2018 18:22

no, I'm using the master branch. And, a little correction, the UI doesn't actually show until I move the mouse pointer over my actual list items. I can move the mouse anywhere on the app, including the blank space at the bottom of the listbox, and nothing appears until the mouse is over an actual listboxitem. Perhaps, it's due to a redraw because of the list item highlight (hover)?

Is there a way to force a redraw?

danwalmsley
@danwalmsley
Dec 13 2018 18:25
@a11smiles you will need to use nightly builds i think some
Fixes have been included fir stuff like this
Including a few days ago to fix black screen on new mojave update
Joshua Davis
@a11smiles
Dec 13 2018 18:27
cool.
Just FYI...I work for MSFT and I have a lot of customers who are asking for something like this. Therefore, I'd like to lead a workshop in March at a .NET conference here in the US to show attendees how to leverage Avalonia. Thanks for the help guys
Jeremy Koritzinsky
@jkoritzinsky
Dec 13 2018 18:38
@a11smiles I also work for Microsoft and am one of the maintainers. If you want to work together on that, let me know! My alias is jekoritz
Steven Kirk
@grokys
Dec 13 2018 19:04

I see the benefit of the Selector...pretty cool. But is there a reason why Avalonia isn't also implementing WPF's traditional attributes like TargetType?

@a11smiles not really. when i started avalonia I was mainly just trying things out, never really imagining that people would want to port their apps from WPF ;) and so didn't give much thought to compatibility. now that people are starting to use it, it's something we take more seriously. i think adding a TargetType property would be do-able but even better might be a more generalized way to add-in a compatibility layer. i know @jkoritzinsky looked into this a a little bit a while ago. we might want to revisit that...

Steven Kirk
@grokys
Dec 13 2018 19:16
though as someone pointed out the other day, MS don't seem to treat compatibility between their XAML frameworks very seriously, so why should we? ;)
Jeremy Koritzinsky
@jkoritzinsky
Dec 13 2018 19:18
The Selector system is also much more powerful than just TargetType property + id.
cbstryker
@cbstryker
Dec 13 2018 20:18
In case anyone runs into the same problem I did, it seems Avalonia doesn't like underscores in the namespace, thus generating the "view not found" error. After spending a day trying to figure out the issue, simply removing the underscore fixed the problem
ahopper
@ahopper
Dec 13 2018 21:04
@cbstryker to add to your experience, starting a project with a - in the name is also a bad idea.
ahopper
@ahopper
Dec 13 2018 21:39
I'm interested in a 'compatability layer'. In trying to share avalonia code with wpfmath ForNeVeR/wpf-math#170 the largest source of noise in the conversion is from the System.windows.media namespace to Avalonia.media for very similar classes like Brush and Color. I had wondered about faking the System.windows.media namespace.
ahopper
@ahopper
Dec 13 2018 21:52
Or faking Avalonia.media for wpf
Kermalis
@Kermalis
Dec 13 2018 23:52
Is x:Type broken or something? I cannot for the life of me get it to work
image.png
image.png
I have no clue how to make a data template for this type if this won't work