-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ViewExtensions and sample #1002
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
Conversation
Added TitleBarExtensions Added StatusBarExtensions Added ApplicationViewExtensions Added documentation for ViewExtensions
|
@timheuer any thoughts on this? |
| viewHelper:StatusBarExtensions.BackgroundColor="Blue" | ||
| viewHelper:StatusBarExtensions.BackgroundOpacity="0.8" | ||
| viewHelper:StatusBarExtensions.ForegroundColor="White" | ||
| viewHelper:StatusBarExtensions.IsVisible="True" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about binding it to property page? This way we could see live change :)
| namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages | ||
| { | ||
| /// <summary> | ||
| /// An empty page that can be used on its own or navigated to within a Frame. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required ;)
| var greyBrush03 = (Color)Application.Current.Resources["Grey-03"]; | ||
| var greyBrush01 = (Color)Application.Current.Resources["Grey-01"]; | ||
|
|
||
| TitleBarExtensions.SetButtonBackgroundColor(this, greyBrush03); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about a kind of recorder: like TitleBarExtensions.SaveState / restoreState
| /// </summary> | ||
| /// <param name="obj">The <see cref="DependencyObject"/> typically <see cref="Page"/></param> | ||
| /// <returns><see cref="Color"/></returns> | ||
| public static Color GetBackgroundColor(DependencyObject obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question that applies to all other properties: Why not attached properties? They could be animated or bound then.
|
@deltakosh the issue there is that title bar / status bar do not have one to one with Page. There's only one instance and that would be the reason why WP7 status bar did not support binding. |
|
Makes sense! |
|
Has this been tested with page navigation? I remember a WinRT app I wrote that had issues with page navigation and change titlebar/statusbar properties when navigating back and forth |
|
@skendrot hence the sample page |
|
There is only one sample page. Has it been tested going to another page that does not want any of the properties set? |
|
Shell and the sample |
|
I can add it to every child it that helps |
|
@skendrot design of underlying object is such that once set they remain until changed |
| /// <summary> | ||
| /// Gets a value indicating whether TitleBar is supported or not. | ||
| /// </summary> | ||
| public static bool IsTitleBarSupported => Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationViewTitleBar"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))?
Or maybe you missed a .?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pproperty and type don't need to match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hermitdave Oh. I didn't know that. Thanks for the info.
| titleBar.InactiveForegroundColor = value; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, could you add a property to update ExtendViewIntoTitleBar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I am sorry. I checked again and it is the same class name TitleBar but it is from another namespace. You can find use it in using CoreApplication.GetCurrentView().TitleBar and the class name is CoreApplicationViewTitleBar. It has 5 properties but I generally only use the ExtendViewIntoTitleBar.
|
Another idea. It could be also useful to handle some properties of |
|
@Odonno I have exposed 2 more properties.. |
|
I still have several questions unanswered :) |
|
@deltakosh I am sure you already have the branch and are tweaking stuff as we speak |
|
@hermitdave For me, it's really good. If you can add the new properties in the documentation, it will be perfect. |
|
@deltakosh so you want me to remove the bind page and the sample page ? or just the bind ? |
|
i want to use the integrated mechanism with IsVisible=[Boolean:True] |
Set xaml binding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name the classes "TitleBar", "StatusBar", etc instead of "StatusBarExtensions", "TitleBarExtensions", etc. This does complicate things for code, but greatly simplifies for xaml.
Should the methods only accept a Page? Right now you could nest the properties into a button if you wanted which wouldn't make sense. Makes more sense to restrict the access to them to a Page
| TitleBarExtensions.SetForegroundColor(this, lightGreyBrush); | ||
| } | ||
|
|
||
| private void Button_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this event created/subscribed to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skendrot vestigial code.
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:viewHelper="using:Microsoft.Toolkit.Uwp.UI.Extensions" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change the namespace declaration to viewExtensions or just extensions. "viewHelper" doesn't make sense for the namespace
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:viewHelper="using:Microsoft.Toolkit.Uwp.UI.Extensions" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change the namespace declaration to viewExtensions or just extensions. "viewHelper" doesn't make sense for the namespace
|
@skendrot being able to attach them makes sense but that requires attached properties. This is something @deltakosh is keen on though. I might close this PR and someone else can pick it up. |
|
@hermitdave Are you referring to this?
If so, I'm merely suggesting to change the method parameter you have from DependencyObject to Page. |
|
@skendrot right you are.. I'll fix the PR if we keep it. |
|
We should keep it. it is clearly useful |
|
I meant we should create a new PR |
|
why? |
|
@skendrot @hermitdave Yeah. Definitely. If we can remove the "Extensions" suffix in xaml, it could improve the readibility of the code. I mean, not necesary but if that's possible, we should do it. |
|
We can merge this one and do a second one for the requested changes if you want @hermitdave :) |
|
@deltakosh i thought you preferred all properties to be bindable |
|
That was the only reason for suggesting this PR be closed |
|
Oh no I was fine with your explanation. |
|
I'll push changes tonight |
|
@skendrot can you review the changes ? |
|
I like the new names. Were you going to change the methods to accept Page instead of DependencyObject? |
|
@skendrot silly me.. Forgot |
| extensions:StatusBar.BackgroundOpacity="0.8" | ||
| extensions:StatusBar.ForegroundColor="White" | ||
| extensions:StatusBar.IsVisible="@[IsVisible:Bool:false]" | ||
| extensions:StatusBar.IsVisible="@[StatusBar IsVisible:Bool:false]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hermitdave Why that change? Does it work like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not!!!
|
@Odonno fixed that.. thanks.. should have tested it on mobile as well!! |
|
@hermitdave Yeah. Great job. I am eager to use it. |

Added TitleBarExtensions
Added StatusBarExtensions
Added ApplicationViewExtensions
Added documentation for ViewExtensions