A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
Hello,
Welcome to our Microsoft Q&A platform!
I want to ask what if my ContentView has a parameter
Yes, you can add parameter like following code. Add new constructor with one parameter.
public partial class MyCustomEntry : ContentView
{
public MyCustomEntry()
{
InitializeComponent();
}
public MyCustomEntry(int id)
{
InitializeComponent();
}
}
Then, if you opening a ContentView dynamically like following code. For example, My project called ImageLongClickDemo, the custom contentview called MyCustomEntry, then I need transfer 1 as parameter, add the parameter in the end of the targetPageType.
var targetPageType = Type.GetType("ImageLongClickDemo." + "MyCustomEntry");
ContentView post_details = (ContentView)Activator.CreateInstance(targetPageType,1);
Best Regards,
Leon Lu
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.