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

Question: Where are the standard UWP Controls ? #1670

Closed
deanchalk opened this issue Nov 24, 2019 · 11 comments
Closed

Question: Where are the standard UWP Controls ? #1670

deanchalk opened this issue Nov 24, 2019 · 11 comments
Labels

Comments

@deanchalk
Copy link

On the WinUI page https://docs.microsoft.com/en-us/uwp/toolkits/winui/ we have this statement

The library also contains updated versions of existing Windows platform controls that you can use with earlier versions of Windows 10.

But when I add the xaml namespace xmlns:controls="using:Microsoft.UI.Xaml.Controls" to my project, the namespace doesnt include standard controls like 'button' or 'checkbox' etc.

Have I confused myself ? how do I get to the WinUI version of a checkbox (for example) rather than the build in version.

Thanks

Dean

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Nov 24, 2019
@marcelwgn
Copy link
Contributor

marcelwgn commented Nov 24, 2019

The way WinUI 2.x functions is the following:

Windows has some build in controls (such as buttons, textblock,...) whose behavior and "logic" comes from the operating system. However the template of those controls can be overridden, by defining a new template in the App.xaml. When installing the WinUI nuget package, you need to add the following lines to the App.xaml

<ResourceDictionary.MergedDictionaries>
  <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
</ResourceDictionary.MergedDictionaries>

By adding this line to your App.xaml file, you tell the xaml compiler to use any template it finds in that dictionary and use that instead of the standard templates. What WinUI does, is just override the templates for the already defined controls. Since the underlaying type is still a windows object, WinUI does not ship new types for those controls. Controls that are introduced with WinUI such as the new NumberBox are defined by WinUI and thus live in the Microsoft.UI.Xaml.Controls namespace.

With WinUI 3.0 this will change, as all controls will be defined in Microsoft.UI.Xaml.Controls.

TL;DR: Controls prior to WinUI are windows types where WinUI overrides the template, that is why you can't find them in the Microsoft.UI.Xaml.Controls namespace.

@deanchalk
Copy link
Author

Thanks a lot for that clarification. This means therefore that an app that target version 2.x will need to be refactored for 3.x as you will be using controls from the wrong namespace.

@marcelwgn
Copy link
Contributor

Yes, unfortunately you will need to refactor your app. However, this should mostly only result in just changing "Windows.UI.Xaml.Controls" to "Microsoft.UI.Xaml.Controls".

With the release of the WinUI 3.0 Alpha, the XAML Controls Gallery was also "ported" to WinUI 3.0 Alpha. While the Alpha does fall short on some areas, a lot was already implemented. If you want to check out what had to be changed, you might want to look at this pull request.

In summary, most changes are changing "Windows.UI.Xaml.Controls" to "Microsoft.UI.Xaml.Controls" and getting rid of some API contracts, since WinUI 3.0 will (as far as I know) not rely heavily on Windows 10 SDK features, but rather ship them inside the nuget package.

@deanchalk
Copy link
Author

OK, Im still confused.

  1. The default 'Button' control sty;e (for example) is exactly the same (in Generic.xaml) between standard UWP button, Winui 2.x and Winui 3 alpha, so the WinUI project is offering nothing so far for changes or improvements to the standard UWP control collection.
  2. The XAML Control Gallery (where there is a Winui3alpha branch to showcase winui3) still references standard UWP controls built into Win 10 - there is no mention of any WinUI replacement for these standard controls so where can I find them - or have they not yet been built.
  3. Where is the Winui3 alpha branch on the microsoft-ui-xaml repo ? Is it in github, or is it being developed in private.

Im just trying to get to the bottom of what we have or dont have in terms on Winui (current version and v3)

Thanks

Dean

@marcelwgn
Copy link
Contributor

I think the first goal of WinUI 3.0 (and the alpha) is to port existing types from build in windows controls into the WinUI repository and nuget package. After that a lot of improvements can be made, however getting there is probably difficult.

Regarding your questions:

  1. I think the reason, why the default button style is exactly the same between those three may be because there were no changes that weren't also done in the SDK (but that is just a guess). However new features and styles are only available through WinUI e.g. reveal style for SplitButton.

  2. Which controls exactly do you mean? Some Windows.UI.* classes are still needed e.g. the colors, but the only situation where we still rely on the Windows.UI.Xaml.Controls controls is related to a library which does not use WinUI 3.0 Alpha. In addition to that, some controls do not work correctly at the time, so I would not use WinUI 3.0 Alpha for production code.

  3. I think WinUI 3.0 gets developed in private and will be made public upon release, however that is just a guess.

@Felix-Dev
Copy link
Contributor

3. Where is the Winui3 alpha branch on the microsoft-ui-xaml repo ? Is it in github, or is it being developed in private.

As @chingucoding said, currently, WinUI 3.0 Alpha is still developed in private. The WinUI team stated though that it is hard at work at open-sourcing the development of WinUI 3.0 so you can expect the source to be made publicly available before the release of WinUI 3.0. The team will perhaps announce more information in one of their upcomming Community Calls, you might want to check out the next one which is scheduled for this wednesday!

@deanchalk
Copy link
Author

@chingucoding - thanks for the reply, I really appreciate it.

Regarding point 2 - if you look at the source for the XAML Control Gallery (Winui3alpha branch) you will see that, for example, the 'Button' demo page references the standard UWP button rather than any button included in the winui package. This is the same for all of the controls that already belong inside UWP - they are referencing the baked-in versions still. I assumed that the Winui v3 (alpha) was going to have brand new controls to replace the baked in UWP controls, but the XAML Control Gallery doesn't reflect this. Hopefully you can help clarify

Thanks

Dean

@deanchalk
Copy link
Author

@Felix-Dev - thanks very much for the clarificatio

Dean

@marcelwgn
Copy link
Contributor

Regarding point 2 - if you look at the source for the XAML Control Gallery (Winui3alpha branch) you will see that, for example, the 'Button' demo page references the standard UWP button rather than any button included in the winui package. This is the same for all of the controls that already belong inside UWP - they are referencing the baked-in versions still. I assumed that the Winui v3 (alpha) was going to have brand new controls to replace the baked in UWP controls, but the XAML Control Gallery doesn't reflect this. Hopefully you can help clarify

Yes, they do not explicitly declare that those are WinUI controls. If you look at the generated files (e.g. ButtonPage.g.cs) you can see that those are all controls from Microsoft.UI.Xaml.Controls.

WinUI 3.0 automatically overwrites the Windows SDK's controls , so the XAML compiler will choose the WinUI controls instead of the Windows SDK.

@deanchalk
Copy link
Author

@chingucoding - Ahhhhh, that makes complete sense. Thanks so much for that insight.
I think all of my questions are now answered - thanks so much

Dean

@marcelwgn
Copy link
Contributor

Happy I could help you :)

@jesbis jesbis closed this as completed Nov 25, 2019
@msft-github-bot msft-github-bot removed the needs-triage Issue needs to be triaged by the area owners label Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants