Repository navigation
WinUI TreeView - #2771
WinUI TreeView#2771
Conversation
|
I have a bit of a dumb question; however, it might be good to discuss. Is there any way to automate the conversion of the C++/WinUI controls to C#/Uno?? TreeView still has a lot of open issues in the WinUI repo and manually pulling those fixes in as they are made... well, it will be impossible to keep Uno up-to-date. Is there any way to combine the T4 code generator, regexs, and some 'custom rules' in order to automate the entire control conversion? This wouldn't be universal as the regexs and custom rules would have to be tweaked for each control. However, once a 'translation' is made the system could detect changes in WinUI and automatically generate the equivalent code for Uno. This keeps coming up all over the place -- with Uno Calc, NumberBox, TreeView, etc... |
|
@robloo at least it might be useful to mark each file with a comment of when it was last changed (to which commit in WinUI it corresponds). This would at least simplify things that we could just do a diff and see all file changes since that time. But agreed, even more automation would be nice even though it is C++ so it could be very tricky |
|
@MartinZikmund Yea, good idea marking a WinUI commit version in each file. That will help a lot to detect the differences and make it easier to manually pull over changes. I'll keep dreaming about automated code conversion :) Great work BTW! |
|
@robloo automating the conversion is particularly tricky. LLVM/Clang offer a way to parse C++ and while there are parts that can be "translated" easily, many others cannot (pointer manipulations specifically). Keeping the original commit hash, preferably in the Uno commit is a good way to keep track. |
7835c21 to
8a2dee4
Compare
|
I will update this to the latest WinUI version and make it ready for review |
bf49aa6 to
c75d107
Compare
…eer and its methods
Includes changes in TreeViewItem, added automation peers
| //WINUI TODO: | ||
| //[TestMethod] | ||
| //public void VerifyVisualTree() | ||
| //{ |
There was a problem hiding this comment.
Codacy found an issue: Remove this commented out code.
| { | ||
| // Unset all override flags to avoid impacting subsequent tests | ||
| //TODO: | ||
| //MaterialHelperTestApi.IgnoreAreEffectsFast = false; |
There was a problem hiding this comment.
Codacy found an issue: Remove this commented out code.
| { | ||
| if (group.Name == "CommonStates") | ||
| { | ||
| commonStates += group.CurrentState.Name + " "; |
There was a problem hiding this comment.
Codacy found an issue: Use a StringBuilder instead.
| func(); | ||
| } | ||
| } | ||
| //var result = dispatcherQueue.TryEnqueue(() => func()); |
There was a problem hiding this comment.
Codacy found an issue: Remove this commented out code.
| var tvi1 = (TreeViewItem)treeView.ContainerFromItem(node1); | ||
| var tvi11 = (TreeViewItem)treeView.ContainerFromItem(node11); | ||
| var tvi12 = (TreeViewItem)treeView.ContainerFromItem(node12); | ||
| var tvi13 = (TreeViewItem)treeView.ContainerFromItem(node13); |
There was a problem hiding this comment.
Codacy found an issue: Remove the unused local variable 'tvi13'.
|
|
||
| //[TestInitialize] | ||
| //public void Setup() | ||
| //{ |
There was a problem hiding this comment.
Codacy found an issue: Remove this commented out code.
| StackPanel stackPanel = new StackPanel(); | ||
| SpecialTreeView inheritedTreeView = new SpecialTreeView(); | ||
| SpecialTreeViewList inheritedTreeViewList = new SpecialTreeViewList(); | ||
| SpecialTreeViewItem inheritedTreeViewItem = new SpecialTreeViewItem(); |
There was a problem hiding this comment.
Codacy found an issue: Remove the unused local variable 'inheritedTreeViewItem'.
| } | ||
| } | ||
|
|
||
| public override void RemoveAt(int index) => RemoveAt(index, true); |
There was a problem hiding this comment.
Codacy found an issue: Remove this default value assigned to parameter 'updateItemsSource'.
| } | ||
| } | ||
|
|
||
| public override void Clear() => Clear(true, true); |
There was a problem hiding this comment.
Codacy found an issue: Remove this default value assigned to parameter 'updateItemsSource'.
| public sealed partial class TreeViewUnrealizedChildrenTestPage : MUXTestPage | ||
| { | ||
|
|
||
| public TreeViewNode VirtualizingTestRootNode; |
There was a problem hiding this comment.
Codacy found an issue: Make 'VirtualizingTestRootNode' private.
| this.InitializeComponent(); | ||
|
|
||
| //TODO: | ||
| //MaterialHelperTestApi.IgnoreAreEffectsFast = true; |
There was a problem hiding this comment.
Codacy found an issue: Remove this commented out code.
|
|
||
| private void OnPropertyChanged(DependencyPropertyChangedEventArgs args) | ||
| { | ||
| DependencyProperty property = args.Property; |
There was a problem hiding this comment.
Codacy found an issue: Remove the unused local variable 'property'.
|
|
||
| private void SetAutomationIdForNodes(TreeView tree) | ||
| { | ||
| var listControl = FindVisualChildByName(this.TestTreeView, "ListControl") as TreeViewList; |
There was a problem hiding this comment.
Codacy found an issue: Remove the unused local variable 'listControl'.
|
|
||
| private void ToggleSelectionMode_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| var selectionMode = TreeViewSelectionMode.Single; |
There was a problem hiding this comment.
Codacy found an issue: Remove this useless assignment to local variable 'selectionMode'.
| { | ||
| public class CustomContent | ||
| { | ||
| public List<CustomContent> Children = new List<CustomContent>(); |
There was a problem hiding this comment.
Codacy found an issue: Make 'Children' private.
| /// </summary> | ||
| public ExpandCollapseState ExpandCollapseState | ||
| { | ||
| get |
There was a problem hiding this comment.
Codacy found an issue: Add a way to break out of this property accessor's recursion.
| return null; | ||
| } | ||
|
|
||
| public static List<T> FindVisualChildrenByType<T>(FrameworkElement parent) where T : class |
There was a problem hiding this comment.
Codacy found an issue: Refactor this method to use a generic collection designed for inheritance.
| var tvi11 = (TreeViewItem)treeView.ContainerFromItem(node11); | ||
| var tvi12 = (TreeViewItem)treeView.ContainerFromItem(node12); | ||
| var tvi13 = (TreeViewItem)treeView.ContainerFromItem(node13); | ||
| var tvi2 = (TreeViewItem)treeView.ContainerFromItem(node2); |
There was a problem hiding this comment.
Codacy found an issue: Remove the unused local variable 'tvi2'.
| else | ||
| { | ||
| //unused variables in MUX source | ||
| //TreeViewItem itemAfterInsertPosition = null; |
There was a problem hiding this comment.
Codacy found an issue: Remove this commented out code.
| { | ||
| if (dispatcherQueue != null) | ||
| // TODO: Uno specific - dispatcher queue is not implemented yet | ||
| if (false)//dispatcherQueue != null) |
There was a problem hiding this comment.
Codacy found an issue: Remove this useless 'if' statement.
| public sealed partial class TreeViewUnrealizedChildrenTestPage : MUXTestPage | ||
| { | ||
|
|
||
| public TreeViewNode VirtualizingTestRootNode; |
There was a problem hiding this comment.
Codacy found an issue: Make this field 'private' and encapsulate it in a 'public' property.
| public sealed partial class TreeViewPage : MUXTestPage | ||
| { | ||
| bool _disableClickToExpand; | ||
| public TreeViewItem flyoutTVI; |
There was a problem hiding this comment.
Codacy found an issue: Make this field 'private' and encapsulate it in a 'public' property.
| // newItems, | ||
| // oldItems, | ||
| // newStartingIndex, | ||
| // oldStartingIndex); |
There was a problem hiding this comment.
Codacy found an issue: Remove this commented out code.
| // - 3 selected | ||
| treeView.SelectAll(); | ||
| Verify.IsNotNull(selectionChangedEventArgs); | ||
| var items = selectionChangedEventArgs.AddedItems.ToList(); |
There was a problem hiding this comment.
Codacy found an issue: Remove the unused local variable 'items'.
| public sealed partial class TreeViewPage : MUXTestPage | ||
| { | ||
| bool _disableClickToExpand; | ||
| public TreeViewItem flyoutTVI; |
There was a problem hiding this comment.
Codacy found an issue: Make 'flyoutTVI' private.
GitHub Issue (If applicable): closes #2720, fixes #3559, resolves #1453, fixes #4165, fixes #4206
PR Type
What kind of change does this PR introduce?
What is the current behavior?
TreeViewcontrol not supported.What is the new behavior?
TreeViewcontrol is supported.ContainerContentChangingevent is called forListViewPR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information
Also fixes several "reveal" brushes in Light and HighContrast mode.