Hello,
After investigation, you could do this by encapsulating custom controls into .NET MAUI class library
.
Please refer to the following steps:
For creating:
Step 1. Created .NET MAUI Class Library project
in Visual Studio. In this example, the default MauiLib1
is used as the project name.
Step 2. Add your custom controls in MauiLib1. In this example, I add a custom Entry control.
public class CusEntry : Entry
{
public CusEntry()
{
this.Text = "test";
this.FontSize = 70;
}
}
For using:
Step 3. Right-click the Solution 'MauiLib1'
in Solution Explorer, and click add -> New Project to create new MAUI project.
Step 4. Right-click on Dependencies
in the MAUI project and select Add Project Reference
, and check your Class Library project.
Step 5. Use the custom Entry in MAUI xaml file.
xmlns:myLib="clr-namespace:MauiLib1;assembly=MauiLib1"
<myLib:CusEntry/>
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.