Skip to content

WinUI TreeView - #2771

Merged
davidjohnoliver merged 76 commits into
unoplatform:masterfrom
MartinZikmund:dev/mazi/treeview
Oct 6, 2020
Merged

davidjohnoliver merged 76 commits into
unoplatform:masterfrom
MartinZikmund:dev/mazi/treeview

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Mar 10, 2020 •

Copy link
Copy Markdown
Member

GitHub Issue (If applicable): closes #2720, fixes #3559, resolves #1453, fixes #4165, fixes #4206

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

TreeView control not supported.

What is the new behavior?

  • TreeView control is supported.
  • ContainerContentChanging event is called for ListView

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Docs have been added/updated which fit documentation template (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

Other information

Also fixes several "reveal" brushes in Light and HighContrast mode.

@gitpod-io

gitpod-io Bot commented Mar 10, 2020 •

Copy link
Copy Markdown

@robloo

robloo commented Mar 11, 2020 •

Copy link
Copy Markdown
Contributor

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...

@MartinZikmund

Copy link
Copy Markdown
Member Author

@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

@robloo

robloo commented Mar 12, 2020

Copy link
Copy Markdown
Contributor

@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!

@jeromelaban

Copy link
Copy Markdown
Member

@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.

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/treeview branch 3 times, most recently from 7835c21 to 8a2dee4 Compare March 17, 2020 18:26
@MartinZikmund MartinZikmund self-assigned this Apr 9, 2020
@MartinZikmund

Copy link
Copy Markdown
Member Author

Some features this PR depend on #2347 and #2346 being fixed

@MartinZikmund

Copy link
Copy Markdown
Member Author

I will update this to the latest WinUI version and make it ready for review

@CLAassistant

CLAassistant commented Jun 10, 2020 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

//WINUI TODO:
//[TestMethod]
//public void VerifyVisualTree()
//{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Remove this commented out code.

{
// Unset all override flags to avoid impacting subsequent tests
//TODO:
//MaterialHelperTestApi.IgnoreAreEffectsFast = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Remove this commented out code.

{
if (group.Name == "CommonStates")
{
commonStates += group.CurrentState.Name + " ";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Use a StringBuilder instead.

func();
}
}
//var result = dispatcherQueue.TryEnqueue(() => func());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


//[TestInitialize]
//public void Setup()
//{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

public override void RemoveAt(int index) => RemoveAt(index, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

public override void Clear() => Clear(true, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public sealed partial class TreeViewUnrealizedChildrenTestPage : MUXTestPage
{

public TreeViewNode VirtualizingTestRootNode;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.InitializeComponent();

//TODO:
//MaterialHelperTestApi.IgnoreAreEffectsFast = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Remove this commented out code.


private void OnPropertyChanged(DependencyPropertyChangedEventArgs args)
{
DependencyProperty property = args.Property;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


private void SetAutomationIdForNodes(TreeView tree)
{
var listControl = FindVisualChildByName(this.TestTreeView, "ListControl") as TreeViewList;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


private void ToggleSelectionMode_Click(object sender, RoutedEventArgs e)
{
var selectionMode = TreeViewSelectionMode.Single;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
public class CustomContent
{
public List<CustomContent> Children = new List<CustomContent>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Make 'Children' private.

/// </summary>
public ExpandCollapseState ExpandCollapseState
{
get

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return null;
}

public static List<T> FindVisualChildrenByType<T>(FrameworkElement parent) where T : class

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var tvi11 = (TreeViewItem)treeView.ContainerFromItem(node11);
var tvi12 = (TreeViewItem)treeView.ContainerFromItem(node12);
var tvi13 = (TreeViewItem)treeView.ContainerFromItem(node13);
var tvi2 = (TreeViewItem)treeView.ContainerFromItem(node2);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else
{
//unused variables in MUX source
//TreeViewItem itemAfterInsertPosition = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Remove this useless 'if' statement.

public sealed partial class TreeViewUnrealizedChildrenTestPage : MUXTestPage
{

public TreeViewNode VirtualizingTestRootNode;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public sealed partial class TreeViewPage : MUXTestPage
{
bool _disableClickToExpand;
public TreeViewItem flyoutTVI;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// newItems,
// oldItems,
// newStartingIndex,
// oldStartingIndex);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Remove this commented out code.

// - 3 selected
treeView.SelectAll();
Verify.IsNotNull(selectionChangedEventArgs);
var items = selectionChangedEventArgs.AddedItems.ToList();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public sealed partial class TreeViewPage : MUXTestPage
{
bool _disableClickToExpand;
public TreeViewItem flyoutTVI;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Make 'flyoutTVI' private.

@MartinZikmund MartinZikmund added the ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met label Oct 1, 2020
@davidjohnoliver
davidjohnoliver merged commit 9bd6b31 into unoplatform:master Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met

Projects

None yet

7 participants