These are chat archives for AvaloniaUI/Avalonia

15th
Nov 2018
Nikita Tsukanov
@kekekeks
Nov 15 2018 07:10
We don't have support for downloading resources from remote locations
You need to load bitmap from a local stream (FileStream, MemoryStream, etc)
BitmapTypeConverter currently doesn't properly handle even file:// uris
Nikita Tsukanov
@kekekeks
Nov 15 2018 10:03
@jmacato if you are going to move datagrid to the main repo make sure to preserve the history
nicolasr75
@nicolasr75
Nov 15 2018 10:25

I want to bind RadioButtons to an Int32 property with valid values 1-8. I have written a Binding Converter for this following WPF examples like this

    public object ConvertBack(object value, Type targetType,
                              object parameter, CultureInfo culture)
    {
        if (value == null || parameter == null)
            return null;

        if (System.Convert.ToBoolean(value))
            return System.Convert.ToInt32(parameter);
        else
            return null;
    }

The converter parameter has the values 1-8 which are set in the xaml. The problem is that returning null always sets my property to 0. I expected it to not change the property in that case. In WPF there is a Binding.DoNothing as a possible return value but this seems not to be available in Avalonia. Any ideas?

Wiesław Šoltés
@wieslawsoltes
Nov 15 2018 10:27
Try AvaloniaProperty.UnsetValue
igorushi
@igorushi
Nov 15 2018 10:29
Hi folks, I'm trying to port a styled wpf application to Avalonia. I have a dedicated style assembly it contains a bunch of ResourceDictionaries with Colors, Sizes, Thickness definitions. How this can be ported to Avalonia? e.g.
<SolidColorBrush x:Key="CustomSliderThumb.Pressed.Border" Color="#FF569DE5"/>
Nikita Tsukanov
@kekekeks
Nov 15 2018 10:31
I think it could be done with StyleInclude
igorushi
@igorushi
Nov 15 2018 10:36
@kekekeks , thanks I'll take a look
cm4ker
@cm4ker
Nov 15 2018 10:36
Guys did you plan intermidiate release then DataGrid will be transfered to the main repo?
To the nuget.org ofc
Nikita Tsukanov
@kekekeks
Nov 15 2018 10:41
It could be released to nuget as is, I think
nicolasr75
@nicolasr75
Nov 15 2018 10:46

@wieslawsoltes The property setter is still called with 0 multiple times. This is the property

private int impulseInputValue = 1;
        public int ImpulseInputValue
        {
            get { return impulseInputValue; }
            set {
                this.RaiseAndSetIfChanged(ref impulseInputValue, value);
            }
        }

Should I simply check for 0 here and don't call RaiseAndSetIfChanged in that case?

Nikita Tsukanov
@kekekeks
Nov 15 2018 14:29
@danwalmsley Did you get your Mac back from repairs?
danwalmsley
@danwalmsley
Nov 15 2018 15:55
Just picked it up now
Ill be home in a couple of hours
So will try out your prs
Kermalis
@Kermalis
Nov 15 2018 16:45
@kekekeks sorry for the late response but my question was about resm resources, not downloading
I ended up using:
        public static Bitmap UriToBitmap(Uri uri)
        {
            var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
            return new Bitmap(assets.Open(uri));
        }
Nikita Tsukanov
@kekekeks
Nov 15 2018 18:12
BitmapConverter does the same thing
Kermalis
@Kermalis
Nov 15 2018 18:31
It was crashing because of context.GetBaseUri(), so I had to make this method
Kermalis
@Kermalis
Nov 15 2018 21:37
Why are there two scrollbars
image.png
<UserControl xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Width="288" Height="512">
  <ScrollViewer VerticalScrollBarVisibility="Auto">
    <ListBox Items="{Binding Messages}"/>
  </ScrollViewer>
</UserControl>
ahopper
@ahopper
Nov 15 2018 21:39
listbox provides its own scrolling
Kermalis
@Kermalis
Nov 15 2018 21:46
Ah I see
Is there a way to force the scrollbar to always be at the bottom? Meaning you won't have to drag to see the newest items that were added, it'd already show them and you'd have to scroll up to see older items instead
ahopper
@ahopper
Nov 15 2018 21:53
there is a scrollintoview method
Kermalis
@Kermalis
Nov 15 2018 22:50
I don't believe that will work with #2004 but I'll try it
Kermalis
@Kermalis
Nov 15 2018 23:06
It doesn't
danwalmsley
@danwalmsley
Nov 15 2018 23:37
@Kermalis that's because strings are compared based on their value
you should have a class like MyItemViewModel
(MessageViewModel) in your case
that wraps your messages
and your selected item property should be of that type,
that will fix you selection binding issue
Kermalis
@Kermalis
Nov 15 2018 23:39
I would've thought that the comparer would go by referenceequals but I guess it would fall back to referenceequals with a wrapper
danwalmsley
@danwalmsley
Nov 15 2018 23:39
thing is with strings, if you had "Test" in the list
and said SelectedItem = "Test"
what would happen
perhaps it could work better if it checked reference equals
but if you follow Mvvm pattern you would wrap it in a ViewModel class and you will not get that issue
if it is an issue or not, im not sure
but that will be a workaround for you
Kermalis
@Kermalis
Nov 15 2018 23:52
alright thanks for the suggestion
I'm not sure what would happen with wpf since I've never used wpf