I am creating a application, in which i have 2 user control,
is it possible that, we have 2 xaml user control page and having 1 code behind xaml.cs file?
I am creating a application, in which i have 2 user control, is it
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Start off by creating three files, first the “code-behind” .cs file is created as a simple class:-
Note it has no
InitializeComponentcall.Now create a new
UserControlthen modify its xaml to look like this:-Note the addition the
xmlns:localalias to point to your app’s namespace then the change of theUserControltag to the base control we actually want.You would modify the .xaml.cs to this:-
That is all the .xaml.cs needs to contain.
You can then repeat this for
SecondMyCommonUserControland so on. Place all the common code in the baseMyCommonUserControlclass.Its a pity MS didn’t anticipate this in the first place, adding an empty virtual InitializeComponent method to the underlying
UserControland having the .g.i.cs auto-generated codeoverridethe method would have meant that we could dispense with this superflous .xaml.cs file in these cases.