c# - Base Pages in XAML Xamarin forms -


i have multiple user controls in xaml shared code want put in base page want

singleline.xaml --> singleline.xaml.cs --- > basepage.cs  doubleline.xaml --> doubleline.xaml.cs --- > basepage.cs 

singleline.xaml

<stacklayout orientation="horizontal" horizontaloptions="fillandexpand" margin="0" backgroundcolor="white">   <stacklayout.gesturerecognizers>     <tapgesturerecognizer tapped="ontapped"/>   </stacklayout.gesturerecognizers>      <stacklayout orientation="horizontal" horizontaloptions="fillandexpand" margin="0"  backgroundcolor="white">         <label x:name="viewtitle" style="{staticresource lbljobdetailname}" />         <label x:name="viewvalue" style="{staticresource lbljobdetailvalue}" />     </stacklayout>    <image x:name="editicon" source="edit.png" margin="15,15,15,15" isvisible="false" widthrequest="15" heightrequest="15" /> </stacklayout> 

singleline.xaml.cs

 using system;  using xamarin.forms;   namespace client.ui.pages.usercontrols  {     public partial class singleline :   client.ui.pages.usercontrols.baseusercontrol     {           // stuff           #region constructors          public singleline()         {               initializecomponent();         }         #endregion     } 

}

basepage.cs

  using system;   using system.collections.generic;    using system.linq;   using system.text;   using system.threading.tasks;   using xamarin.forms;    namespace client.ui.pages.usercontrols   {      public class baseusercontrol: xamarin.forms.contentview      {           public baseusercontrol()           {           }      }   } 

the system wont compile , following error

 error  cs0234  type or namespace name 'baseusercontrol' not exist in namespace 'client.ui.pages.usercontrols' (are missing assembly reference?)    client.ui   c:\projects\client.ui\pages\usercontrols\singlelineitem.xaml.cs 8   active 

this seems simple thing causing headache, ideas ?

should be:

 using system;  using xamarin.forms;  namespace client.ui.pages.usercontrols {    public partial class singleline :   client.ui.pages.usercontrols.baseusercontrol    {       // stuff       #region constructors        public singleline()       {          initializecomponent();       }       #endregion    .... etc   } // end of class } 

also not need explicitly declare name space both singleline , baseusercontrol in same namespace....

 public partical class singleline : baseusercontrol 

this should work....


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -