I have a folder of components under the Shared directory.
>Shared
+Components
+MyComponentType1
-MyComponentType1Base.razor
-MyComponentType1Title.razor
+MyComponentType2
-MyComponentType2Base.razor
-MyComponentType2Title.razor
-MainLayout.razor
To include all the elements of the components subfolders i have to write all the using statements in the _Imports.razor
@using MyApp.Shared.Components.MyComponentType1
@using MyApp.Shared.Components.MyComponentType2
So my question is : Is there a way to regroup all the components in the subfolders in the Component directory so that i'd use only one using statement?
@using MyApp.Shared.Components
The @namespace
directive was added a few versions back. You can use this to override the default namespace of your components which is the folder path by default.
+MyComponentType1
-MyComponentType1Base.razor
-MyComponentType1Title.razor
+MyComponentType2
-MyComponentType2Base.razor
-MyComponentType2Title.razor
MyComponentType1Title.razor
@namespace MyComponents
<span>Component implementation</span>
MyComponentType2Title.razor
@namespace MyComponents
<span>Component implementation</span>
_Imports.razor
@using MyComponents
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With