question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: alternative "using:" syntax to include namespace to XAML file

See original GitHub issue

Currently Avalonia supports WPF’style namespaces in XAML files, using clr-namespace with assembly. With that we need to provide long path to assemblies, if namespace isn’t contained in current one. UWP and XF supports another syntax, using “using:” keyword (for UWP it is only one available syntax). With this we don’t need to provide assembly, instead it will internally search for namespace in referenced projects and packages.

Proposal syntax:

<Styles xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="using:System"
        xmlns:controls="using:MyNamespaceInAnotherAssembly">
  <Style Selector="controls|MyControl" />
</Window>

UWP docs: https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/xaml-namespaces-and-namespace-mapping#mapping-custom-types-to-xaml-namespaces-and-prefixes

Xamarin Forms docs: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/namespaces#declaring-namespaces-for-types

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
jkoritzinskycommented, Aug 1, 2020

I added this to the WinUI prototype Xaml compiler based on XamlX, and this is pretty easy to add to the XamlX library.

2reactions
FoggyFindercommented, Aug 5, 2020

“using:” is well known UWP and XF syntax not only for C#, but also for F#/VB/C++ projects as well.

Just because UWP doesn’t care about anything except C#. To use it properly (release mode = .net native) you have to edit gatekeeper config manually. At least for F# for sure. I doubt the situation is better for VB (which is literally dead for Microsoft) and C++/CLI.

Also not all developers who use Avalonia have previous UWP/XF/WPF background, besides there are features that specific only to Avalonia already (at least I think so).

From the start Avalonia has better F# support than the rest of .net - ui - frameworks. Providing one alternative synonym for keyword doesn’t sound like a big deal but it allows write more idiomatic code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

XAML Custom Namespace Schemas in Xamarin.Forms
An alternative approach is to define a custom namespace schema, such as http://mycompany.com/schemas/controls , that maps to one or more CLR ...
Read more >
What happens when I import a namespace in XAML?
I have been wondering whether it would make more sense to put all of my controls into a more centralised namespace that I...
Read more >
Using namespaces: Aliasing/Importing - Manual
Here is an example showing all 5 kinds of importing: Example #1 importing/aliasing with the use operator. <?php namespace foo; use My\Full\Classname as ......
Read more >
Namespace - Wikipedia
In computing, a namespace is a set of signs (names) that are used to identify and refer to objects of various kinds. A...
Read more >
Google C++ Style Guide
These rules exist to keep the code base manageable while still allowing coders to use C++ language features productively. Style, also known as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found