Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Expander): add ability to change expander orientation #1336

Merged
merged 7 commits into from
Aug 21, 2017
Merged

feat(Expander): add ability to change expander orientation #1336

merged 7 commits into from
Aug 21, 2017

Conversation

Odonno
Copy link
Contributor

@Odonno Odonno commented Jul 24, 2017

Linked to #922 where @hawkerm requested Expander DIrection/Orientation.

Might also solve #923 because I needed to handle Expander Toggle Button orientation using a LayoutTransformer, the RenderTransform component does not render very well in this case. I reused the LayoutTransformer control from this blog post http://igrali.com/2012/09/17/layout-transform-in-windows-8-winrt-xaml/

@skendrot
Copy link
Contributor

Did you take a look a look at the LayoutTransformControl from the WinRT XAML Toolkit by @xyzzer?

@Odonno
Copy link
Contributor Author

Odonno commented Jul 24, 2017

@skendrot Seems very similar. One interesting thing is that this control handle PropertyChange of Value of Transform component (like the change on Angle of RotateTransform).

Should I add the dependency to this Library and use this control instead of the one I recreated?

Copy link
Contributor

@skendrot skendrot left a comment

Choose a reason for hiding this comment

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

Quick review. Will need to do a more detailed review later

/// <summary>
/// Key of the VisualStateGroup that set orientation of the control
/// </summary>
public const string OrientationGroupStateContent = "OrientationStates";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these public?


namespace Microsoft.Toolkit.Uwp.UI.Controls
{
public enum ExpanderOrientation
Copy link
Contributor

Choose a reason for hiding this comment

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

How about ExpandDirection

/// <summary>
/// Top
/// </summary>
Top,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the same values as WPF
Down,
Up,
Left,
Right

// Can't tab to LayoutTransformer
IsTabStop = false;

#if SILVERLIGHT
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll never be Silverlight

return;
}

if (Orientation == ExpanderOrientation.Left)
Copy link
Contributor

Choose a reason for hiding this comment

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

change to a switch statement

}

// Apply rotation on expander toggle button
layoutTransformer.ApplyLayoutTransform();
Copy link
Contributor

Choose a reason for hiding this comment

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

could be null if styled out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand. Null is checked before using the method.

@@ -0,0 +1,537 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
Copy link

Choose a reason for hiding this comment

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

Can we incorporate this code like this and re-license it as it's from the SO post?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hawkerm Good question. I checked and the code in blog post is originally from Silverlight XAML, so it is already the property of Microsoft. So, I suppose we can.

@hawkerm
Copy link

hawkerm commented Jul 24, 2017

If the other LayoutTransformControl behaves in the same manner, I'd suggest to use it with the clearer license term compatibility.

@skendrot
Copy link
Contributor

Does the header need to rotate? The WPF Expander never did

@Odonno
Copy link
Contributor Author

Odonno commented Jul 24, 2017

The two options are possible IMO. But clearly, we should not reinvent the wheel and reuse the WinRTXamlToolkit.

@Odonno
Copy link
Contributor Author

Odonno commented Jul 24, 2017

@skendrot I need to rotate because the Header content should rotate if you want the header text to rotate. If there was only the arrow icon, we should not need it.

@skendrot
Copy link
Contributor

if you want the header text to rotate

My question is why does that have to be the default? Why have it built in? If the dev wants the header text to rotate, they can pull in the WinRTXamlToolkit and restyle. I don't think this toolkit needs a LayoutTransform when an established toolkit already has it.

@Odonno
Copy link
Contributor Author

Odonno commented Jul 24, 2017

@skendrot I now use the control from WinRTXAMLToolkit. It works exactly like before and I removed the LayoutTransform control from the UWP Toolkit.

@skendrot
Copy link
Contributor

But should this toolkit have a dependency on WinRTXamlToolkit?
In short, I don't think we need to rotate the text. I would vote to remove this completely

@Odonno
Copy link
Contributor Author

Odonno commented Jul 24, 2017

@skendrot If I don't do it, it will not look pretty. If left or right oriented, the header will take too much space. I don't think that's what we want.

@Odonno
Copy link
Contributor Author

Odonno commented Jul 24, 2017

Without LayoutTransform :

image

@skendrot
Copy link
Contributor

skendrot commented Jul 24, 2017

Would need to fix the stretch of the header and the direction of the arrow.
Here's the same on WPF.
image

Using the following XAML

<Expander Header="This is the header" Background="Blue" IsExpanded="True" ExpandDirection="Right">
    <Grid Background="Red">
        <TextBlock Text="This is the content"/>
    </Grid>
</Expander>

@skendrot
Copy link
Contributor

Remember that more than text can go into the header. Could easily put text with images and other information into the header. You would not want this rotated.

@Odonno
Copy link
Contributor Author

Odonno commented Jul 24, 2017

Because the Header contains the arrow, the arrow is also rotated thanks to the LayoutTransform.

In my opinion, since the Header is on the side (reading it vertically and not horizontally), it feels "normal" to me that all the content is rotated, even if it is not only text.

@hawkerm
Copy link

hawkerm commented Jul 25, 2017

It does seem heavy to add a whole new dependency; not sure about copying it out for inclusion here, is that generally done?

From a UX perspective, I think most people expect the text to be rotated in these cases (that's the default I've seen for other libraries). But if we're trying to be WPF compatible, then we probably want to leave the behavior the same.

I think though if rotating is not the default and has to be done through restyling, it'd be good to have a sample that shows how to do that as it is a common usage.

@Odonno Odonno added this to the v2.0 milestone Jul 25, 2017
@skendrot
Copy link
Contributor

Yes. I agree that some sort of sample, either in the toolkit itself or via a blog post would help here.

@nmetulev
Copy link
Contributor

nmetulev commented Aug 6, 2017

@xyzzer, any concerns with moving the LayoutTransformControl to the toolkit?

@xyzzer
Copy link

xyzzer commented Aug 7, 2017

Hi guys, sorry for ignoring this thread. Work's been busy and I've been ignoring emails from UWP Community Toolkit.

I totally think you should use LayoutTransformControl if it's been shown to work. I haven't heard complaints. Can't recall where I took it from, but I might have simply ported the code from Silverlight Toolkit rather than writing my own version, so the quality should be great, right? :)

Also - I recommend just copying the code, but this is a very subjective opinion. My opinion of WinRT XAML Toolkit itself has grown to be that people should totally use it for quickly sketching apps, prototypes, etc. and all the controls and helpers available at their fingertips, but as soon as you start working on an app you'd like to ship - you should strongly consider copying and pasting the code out of the toolkit to make sure you're not dragging along a few megabytes of dead code to download and load with your app. Yes, you'd lose the benefit of updates to the toolkit benefiting future builds of your app, but I don't actually update it that frequently anyways and so you're more likely to fix the bugs yourself if they're in your own source code. I considered breaking the toolkit apart more granularly so that every component would be its own NuGet package, but that turned out to be a very daunting task that I quickly dropped and so there are only a few NuGet packages with larger and more loosely related sets of components. For UWP Community Toolkit thus it would make sense to similarly - include a copy of the source, so that people can use it easily without dragging along hidden dependencies with different namespaces and also so that if they want to see how things work in that control - they only have to use at the UWP Community Toolkit source instead of spelunking a bunch of different GitHub repos.

@nmetulev
Copy link
Contributor

nmetulev commented Aug 8, 2017

Great insight. I think we are all in agreement at this point, @Odonno, what do you think?

@@ -16,6 +16,7 @@
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Markup;
using WinRTXamlToolkit.Controls;
Copy link

Choose a reason for hiding this comment

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

Make sure to move it to a better namespace.

Copy link

@xyzzer xyzzer left a comment

Choose a reason for hiding this comment

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

Please update the namespaces from WRTXT to UWPCT

@Odonno
Copy link
Contributor Author

Odonno commented Aug 9, 2017

@nmetulev I'm fine with it. Like I said, both options are possible. I'll copy the code and import it in the Toolkit.

@Odonno
Copy link
Contributor Author

Odonno commented Aug 12, 2017

@nmetulev @xyzzer Done.

@xyzzer
Copy link

xyzzer commented Aug 12, 2017 via email

Copy link
Contributor

@nmetulev nmetulev left a comment

Choose a reason for hiding this comment

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

Could you also update the docs for the Expander to include the new property and add documentation for the LayoutTransformControl?

{
/// <summary>
/// Control that implements support for transformations as if applied by
/// LayoutTransform (which does not exist in Silverlight).
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the bit about Silverlight be removed?

Copy link
Contributor Author

@Odonno Odonno Aug 17, 2017

Choose a reason for hiding this comment

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

All comments about Silverlight? I can do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, unless you believe those are relevant?

{
/// <summary>
/// Control that implements support for transformations as if applied by
/// LayoutTransform (which does not exist in Silverlight).
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@xyzzer
Copy link

xyzzer commented Aug 17, 2017 via email

@azchohfi azchohfi merged commit c2c9a04 into CommunityToolkit:dev Aug 21, 2017
@Odonno Odonno deleted the expanderOrientation branch August 22, 2017 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants