These are chat archives for AvaloniaUI/Avalonia

16th
Jan 2016
Wiesław Šoltés
@wieslawsoltes
Jan 16 2016 14:12
@grokys Reagarding the DropDown issue, I can not just bind to TextBox Text property, as my DataType is generic Library<T> and this does not work in xaml
this is my WPF equivalent XAML:
        <ComboBox ItemsSource="{Binding StyleLibraries}" SelectedItem="{Binding CurrentStyleLibrary}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="2,2,2,2">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Delay=500}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
you can see that I do not have specify the DataTemplate DataType so I can use generics
Steven Kirk
@grokys
Jan 16 2016 14:15
ah
yeah, that's a separate problem
is there a non-generic base class that you can apply the template to?
Wiesław Šoltés
@wieslawsoltes
Jan 16 2016 14:16
no
Steven Kirk
@grokys
Jan 16 2016 14:16
could you try just applying the template to object then?
Wiesław Šoltés
@wieslawsoltes
Jan 16 2016 14:16
will try
Steven Kirk
@grokys
Jan 16 2016 14:19
actually, i think i can just remove the need to have a DataType as in WPF
Wiesław Šoltés
@wieslawsoltes
Jan 16 2016 14:19
that would be great
ok so changing to Object works:
<DropDown
    Items="{Binding Path=StyleLibraries}"
    SelectedItem="{Binding Path=CurrentStyleLibrary, Mode=TwoWay}"
    Grid.Row="2"
    Classes="default">
    <DropDown.DataTemplates>
        <DataTemplate DataType="sys:Object">
            <TextBlock Text="{Binding Name}" Classes="default"/>
        </DataTemplate>
    </DropDown.DataTemplates>
</DropDown>
Nikita Tsukanov
@kekekeks
Jan 16 2016 14:20

actually, i think i can just remove the need to have a DataType as in WPF

And how intellisense is expected to guess the type then?

Steven Kirk
@grokys
Jan 16 2016 14:21
it doesn't need to
Nikita Tsukanov
@kekekeks
Jan 16 2016 14:21
I still hope to get some intellisense support for bindings
Steven Kirk
@grokys
Jan 16 2016 14:21
yeah, well if there's a DataType it can provide it. if no DataType - no intellisense
that's fair enough i think
right, i've committed that change so you can remove the Object DataType as in WPF
we really need to be able to specify generic types in xaml...
Wiesław Šoltés
@wieslawsoltes
Jan 16 2016 14:24
something like DataType="core:Library{core:ShapeStyle}" would be great
Steven Kirk
@grokys
Jan 16 2016 14:24
yeah
i'll add an issue
Wiesław Šoltés
@wieslawsoltes
Jan 16 2016 14:41
@grokys Thanks for quick fixes, now its working!
@grokys I have found issues with TreeView not updating when bound collection is updated and the throwing exception when trying to select TreeView item
Exception thrown: 'System.NullReferenceException' in Perspex.Interactivity.dll
Core2D.Perspex.vshost.exe Error: 0 : Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.
   w Perspex.Controls.TreeView.MarkContainerSelected(IControl container, Boolean selected)
   w Perspex.Controls.TreeView.UpdateSelectionFromContainer(IControl container, Boolean select, Boolean rangeModifier, Boolean toggleModifier)
   w Perspex.Controls.TreeView.UpdateSelectionFromEventSource(IInteractive eventSource, Boolean select, Boolean rangeModifier, Boolean toggleModifier)
   w Perspex.Controls.TreeView.OnPointerPressed(PointerPressEventArgs e)
   w Perspex.Interactivity.RoutedEvent`1.ClassHandlerAdapter[TTarget](Object sender, RoutedEventArgs e, Func`2 handler)
   w Perspex.Interactivity.RoutedEvent`1.<>c__DisplayClass1_0`1.<AddClassHandler>b__0(Object s, RoutedEventArgs e)
--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---
   w Perspex.Interactivity.RoutedEvent.InvokeClassHandlers(Object sender, RoutedEventArgs e)
   w Perspex.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e)
   w Perspex.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e)
   w Perspex.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
   w Perspex.Input.MouseDevice.MouseDown(IMouseDevice device, UInt32 timestamp, IInputElement root, Point p, MouseButton button, InputModifiers inputModifiers)
   w Perspex.Input.MouseDevice.ProcessRawEvent(RawMouseEventArgs e)
   w System.Reactive.AnonymousSafeObserver`1.OnNext(T value)
   w System.Reactive.Linq.ObservableImpl.Where`1._.OnNext(TSource value)
   w System.Reactive.Linq.ObservableImpl.OfType`2._.OnNext(TSource value)
   w System.Reactive.Observer`1.OnNext(T value)
   w Perspex.Input.InputManager.Process(RawInputEventArgs e)
   w Perspex.Controls.TopLevel.HandleInput(RawInputEventArgs e)
   w Perspex.Controls.Platform.PlatformManager.WindowDecorator.OnInput(RawInputEventArgs obj)
   w Perspex.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   w Perspex.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   w Perspex.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   w Perspex.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   w Perspex.Application.Run(ICloseable closable)
   w Core2D.Perspex.App.Start() w C:\DOWNLOADS\GitHub-Core2D\Core2D\Core2D.Perspex\App.paml.cs:wiersz 122
Wiesław Šoltés
@wieslawsoltes
Jan 16 2016 14:47
this is the TreeView Xaml:
<TreeView
    Items="{Binding Path=Documents, Mode=TwoWay}"
    SelectedItem="{Binding Path=Selected, Mode=TwoWay}"
    Grid.Row="2"
    Classes="default">
    <TreeView.DataTemplates>
        <TreeDataTemplate DataType="core:Document" ItemsSource="{Binding Path=Pages, Mode=TwoWay}">
            <TextBlock Text="{Binding Path=Name, Mode=TwoWay}" Classes="default"/>
        </TreeDataTemplate>
        <DataTemplate DataType="core:Page">
            <TextBlock Text="{Binding Path=Name, Mode=TwoWay}" Classes="default"/>
        </DataTemplate>
    </TreeView.DataTemplates>
</TreeView>
looks to me like ItemsSource collection changes in TreeDataTemplate do not update the UI
Steven Kirk
@grokys
Jan 16 2016 14:55
yeah, as i mentioned in your issue - i'm aware of this
it's something i ran into myself recently and so i'll be fixing it
Wiesław Šoltés
@wieslawsoltes
Jan 16 2016 15:00
ok, was searching issues but did not find this one