Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

UserControl inheritance #100

Open
birbilis opened this issue May 16, 2017 · 5 comments
Open

UserControl inheritance #100

birbilis opened this issue May 16, 2017 · 5 comments

Comments

@birbilis
Copy link

I remember I had issues with UserControl inheritance when trying to reuse (via file linking) XAML+code between Silverlight and WPF. Silverlight 5 supported it, but WPF didn't. Was some issue with WPF using BAML (compiled XAML) that could potentially be bypassed by loading XAML dynamically, but then one lost visual designer support in Visual Studio.

In WPF one could subclass in XAML a UserControl as long as that first control was defined just in code, without any XAML (vice versa too should work I guess). So I ended up converting the ancestor UserControls from XAML+codebehind to just the codebehind with commands to construct the control UI dynamically in the constructor. That was portable between Silverlight and WPF.

Not sure what is the case in UWP or Xamarin.Forms regarding visually inheriting from UserControls that were also defined visually (using XAML and optional codebehind that is). Nor if Visual Studio tooling supports that scenario correctly

@zbamstudio
Copy link

It's the same case with UWP also. Very counter intuitive.

@birbilis
Copy link
Author

btw, it wasn't always straightforward to convert XAML to commands (to construct UI programmatically). In my opinion there should be a straighforward mapping and maybe automated tool to convert from XAML to code and maybe vice-versa too (as long as the code kept same style as the one generated from XAML via the tool)

@mossyblog
Copy link

Revert back to i guess the "old way" whereby you declaring the Parent controls is inherited by the child control.

<myParent:myChild x:Class="Path.to.myChild"/>

Note: Pathing should be deferred to the style of the implementation of the XAML, meaning it doesn't always have to be a namespace can be direct folder/file path similar to Java. As if a Java platform could implement XAML tomorrow they would occupy a different approach to .NET

Its then up to the platform/tooling to uphold that contract. The standard should declare that this is enforced rule and any ad-hoc cherry picking of any kind is deemed to break the "standard" compliance matrix.

In doing this it should relieve the pressure of "it kind of worked in the past vs future" given the moment a break in acceptance here would result in such concrete implementation as "not standard compliant" (which is bad smell time).

@AtosNicoS
Copy link

Are there any updates on this issue?

@birbilis
Copy link
Author

birbilis commented Dec 3, 2019

BTW, we know Silverlight supported it and WPF didn't, does UWP support such inheritance (guess it does have UserControls)?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants