Git Product home page Git Product logo

Comments (7)

Coloryr avatar Coloryr commented on May 15, 2024 1

Only this code can be used now

<TreeDataGrid.Resources>
                        <DataTemplate x:Key="FileNameCell1" DataType="m:FileTreeNodeModel">
                            <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}" />
                        </DataTemplate>
Columns =
                {
                    new TemplateColumn<FileTreeNodeModel>(
                            "Name",
                            "FileNameCell1",
                            options: new ColumnOptions<FileTreeNodeModel>
                            {
                                CanUserResizeColumn = false
                            }),

GIF

from avalonia.controls.treedatagrid.

turowicz avatar turowicz commented on May 15, 2024

cc @grokys @wieslawsoltes

from avalonia.controls.treedatagrid.

SuperJMN avatar SuperJMN commented on May 15, 2024

How can I make it so when I check a hierarchy node, then all subitems get also checked in a cascade way?

I imagine that you want something like this: zkSNACKs/WalletWasabi#9089 (review)

You will want a MultiSelector
And a column like this: https://github.com/SuperJMN/WalletWasabi/blob/465980eb6b900e8ef050f2582ad872f0f9157b09/WalletWasabi.Fluent/ViewModels/CoinSelection/Core/ColumnFactory.cs#L103

If you need more help, ping me and I will see if I can prepare a sample for you.

from avalonia.controls.treedatagrid.

turowicz avatar turowicz commented on May 15, 2024

@SuperJMN a sample would be lovely.

I tried this but it doesn't trigger a draw. This mean that I need to scroll the list to see the visual changes.

    public class TreeItem : INotifyPropertyChanged
    {
        private bool _checked;

        public TreeItem()
        {
            Children.CollectionChanged += DataCollectionChanged;
        }

        public string Display { get; set; }

        public dynamic Object { get; set; }

        public bool Checked
        {
            get
            {
                return _checked;
            }
            set
            {
                _checked = value;

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(nameof(Checked)));
                }
            }
        }

        public ObservableCollection<TreeItem> Children { get; set; } = new ObservableCollection<TreeItem>();

        public event PropertyChangedEventHandler? PropertyChanged;

        public override string ToString()
        {
            return Display;
        }

        private void DataCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null)
            {
                foreach (INotifyPropertyChanged item in e.OldItems)
                {
                    item.PropertyChanged -= ItemPropertyChanged;
                }
            }

            if (e.NewItems != null)
            {
                foreach (INotifyPropertyChanged item in e.NewItems)
                {
                    item.PropertyChanged += ItemPropertyChanged;
                }
            }
        }

        public static void ItemPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (sender is TreeItem item)
            {
                var isChecked = item.Checked;

                foreach(var child in item.Children)
                {
                    child.Checked = isChecked;

                    ItemPropertyChanged(child, null);
                }
            }
        }
    }

from avalonia.controls.treedatagrid.

turowicz avatar turowicz commented on May 15, 2024

I feel like this is a standard feature to be expected from a Tree control with checkboxes. It should have been implemented in #127

from avalonia.controls.treedatagrid.

turowicz avatar turowicz commented on May 15, 2024

@SuperJMN @grokys @wieslawsoltes anyone please help, I'm stuck on this:

Screencast.from.2022-10-22.13-24-27.webm

from avalonia.controls.treedatagrid.

turowicz avatar turowicz commented on May 15, 2024

It only updates the drawing after the CheckboxColumn items fall below the fold

from avalonia.controls.treedatagrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.