Open KentSwan opened 9 months ago
In some derivative testing, I found that in the CommunityToolkit.Mvvm variant view would not be initialized when the tab was selected the first time. This was because the load function for the ViewModel's drive data had not been set up before the view was initialized. Adding setting the view DataContext in the View's constructor solves this issue. See the code below.
namespace TreeDataGridDemo.Views
{
public partial class WikipediaPageView : UserControl
{
public WikipediaPageView()
{
InitializeComponent();
this.DataContext = new WikipediaPageViewModel();
}
}
}
Avalonia.Controls.TreeDataGridDemo.2024-02-26.zip file attached contains working ReactiveUI and CommunityToolkit.MVVM MVVM form projects as an alternative to the equivalent in the GitHub TreeDataGrid distribution. This new code base has been updated to include the initialization update noted above as well as removing the use of stack panel in MainWindow.axaml as the TabControl Views container for TreeDataGrid views. (See issues and solutions found posted separately relating to the TreeDataGrid scroll bars being functional and visible).
I hope this work provides a Rosetta Stone-like capability for other developers. Going through this code normalization, transformation, and evolution exercise for the two Avalonia MVVM support systems has been an eye-opening learning experience.
Would you mind publishing this as a github repo? I'm a bit apprehensive to download a random zip, but it sounds interesting!
This is the file was done with 7zip on my windows development computer. It should be fine. You should be able to just unzip it into a folder in your project compile area and then act and then compile it. What I did was to go through and remove and or replace anything associated with reactive UI in order to get a pure Community toolkit version. I do have a private GitHub but that's for my company operation. I do not maintain a public GitHub repository but thanks for asking.
On Fri, Aug 23, 2024, 4:03 PM jacob @.***> wrote:
Would you mind publishing this as a github repo? I'm a bit apprehensive to download a random zip, but it sounds interesting!
— Reply to this email directly, view it on GitHub https://github.com/AvaloniaUI/Avalonia.Controls.TreeDataGrid/issues/263#issuecomment-2307735804, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB35NILSJKU2JLGMK77GS23ZS6ISJAVCNFSM6AAAAABDYSGQDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBXG4ZTKOBQGQ . You are receiving this because you authored the thread.Message ID: @.*** com>
Using GitHub download of TreeDataGrid as of 2024-02-23 as a base I have rebuilt separate versions of TreeDataGridDemo in proper Mvvm format. Separate projects one using ReactiveUI and the other CommunityToolkit.Mvvm are operationally identical to the sample demo from the Avalonia.TreeDataGrid snapshot downloaded from the Github repository. Both of the derivative demo projects use net8.0 and all required Nuget packages are updated to their most current versions. This reference information is documented in the MainWindowViewModel.cs file of each variant.
These implement correctly constructed View-ViewModel pairing such that the views are completely independent. These independent views are then individually inserted into TabItems of a TabControl in MainView.axaml.
The conversion process was first from the GitHub version to a standalone ReactiveUI MVVM variant. Once this version was operating properly, it provided the base for the CommunityToolkit.Mvvm variant. Each project has notes embedded relating to that aspect of the conversion.
This attached sample code is intended to be a rosetta stone accessible by anyone. Feel free to review and comment on anything.
Avalonia.Controls.TreeDataGridDemo 2024-02-23.zip