microsoft / xaml-standard

XAML Standard : a set of principles that drive XAML dialect alignment
Other
804 stars 50 forks source link

UserControl inheritance #100

Open birbilis opened 7 years ago

birbilis commented 7 years ago

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 commented 7 years ago

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

birbilis commented 7 years ago

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 commented 7 years ago

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

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 commented 4 years ago

Are there any updates on this issue?

birbilis commented 4 years ago

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