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

Extend documentation on how to change window base class in XAML #19

Closed
chausner opened this issue Jan 17, 2022 · 4 comments
Closed

Extend documentation on how to change window base class in XAML #19

chausner opened this issue Jan 17, 2022 · 4 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@chausner
Copy link

I got the following error after changing the base class to WindowEx in the code-behind:

error CS0263: Partial declarations of 'MainWindow' must not specify different base classes

Took me a few minutes to figure out that I would need to change the tag name in XAML, as well:

<winuiex:WindowEx
    xmlns:winuiex="using:WinUIEx">
</winuiex:WindowEx>

I suggest to extend the documentation by mentioning this fact and ideally including some sample code to make this clearer to users.

@dotMorten dotMorten added documentation Improvements or additions to documentation good first issue Good for newcomers labels Jan 17, 2022
@TRadigk
Copy link

TRadigk commented Feb 9, 2022

@chausner are you able to elaborate further? I am trying to adapt my code from Window to WindowEx, but I am failing miserably.
I can do this:

<Window
    x:Class="Ennex.MainWindow:WindowEx"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Ennex"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:views="using:Ennex.Views"
    mc:Ignorable="d">


which solves the errors in c# code of MainWindow.xaml.cs, but then I get errors everywhere on "InitializeComponent".
Using Windows App SDK 1.0.0 Release

@chausner
Copy link
Author

chausner commented Feb 9, 2022

@TRadigk This should work:

<winuiex:WindowEx
    x:Class="Ennex.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Ennex"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:views="using:Ennex.Views"
    xmlns:winuiex="using:WinUIEx"
    mc:Ignorable="d">
...
</winuiex:WindowEx>

@TRadigk
Copy link

TRadigk commented Feb 10, 2022

It feels like a thumbs up is not enough: @chausner thank you!

@dotMorten
Copy link
Owner

Better? https://dotmorten.github.io/WinUIEx/concepts/WindowEx.html#usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants