controltemplate - Xamarin.Forms default control templates -


i adjust default controltemplate of button. in wpf use blend see default controltemplate xamarin.forms can not use blend.

also in app.xaml file see reference

<resourcedictionary source="resource dictionaries/standardstyles.xaml"/> 

but not find standardstyles.xaml file out of luck there well.

and on xamarin site not find default controltemplates neither. where/how can find default controltemplates xamarin.forms controls?

at point, xamarin.forms doesn't provide templating support buttons - there no default template(s) refer (as in wpf) or controltemplate property in button. renders platform version of button in target platform.

control templates supported controls have content property. example contentview. can write custom button control while extending contentview, while providing templating support, , use contentpresenter render associated button.

edit 1 - custom button control templated support

for example:

public class templatedbutton : contentview {     public templatedbutton()     {         var button = new button();         button.setbinding(button.textcolorproperty, new binding(nameof(textcolor), source: this));         button.setbinding(backgroundcolorproperty, new binding(nameof(backgroundcolor), source: this));          button.setbinding(isenabledproperty, new binding(nameof(isenabled), source: this));         button.setbinding(button.textproperty, new binding(nameof(text), source: this));          button.setbinding(button.commandproperty, new binding(nameof(command), source: this));         button.setbinding(button.commandparameterproperty, new binding(nameof(commandparameter), source: this));          var tapgesturerecognizer = new tapgesturerecognizer();         tapgesturerecognizer.setbinding(tapgesturerecognizer.commandproperty, new binding(nameof(command), source: this));         tapgesturerecognizer.setbinding(tapgesturerecognizer.commandparameterproperty, new binding(nameof(commandparameter), source: this));         gesturerecognizers.add(tapgesturerecognizer);          content = button;     }      public static readonly bindableproperty textproperty =         bindableproperty.create(             "text", typeof(string), typeof(templatedbutton),             defaultvalue: default(string));      public string text     {         { return (string)getvalue(textproperty); }         set { setvalue(textproperty, value); }     }      public static readonly bindableproperty commandproperty =         bindableproperty.create(             "command", typeof(icommand), typeof(templatedbutton),             defaultvalue: new command((obj) => system.diagnostics.debug.writeline("templatedbutton tapped")));      public icommand command     {         { return (icommand)getvalue(commandproperty); }         set { setvalue(commandproperty, value); }     }      public static readonly bindableproperty commandparameterproperty =         bindableproperty.create(             "commandparameter", typeof(object), typeof(templatedbutton),             defaultvalue: default(object));      public object commandparameter     {         { return (object)getvalue(commandparameterproperty); }         set { setvalue(commandparameterproperty, value); }     }      public static readonly bindableproperty textcolorproperty =         bindableproperty.create(             "textcolor", typeof(color), typeof(templatedbutton),             defaultvalue: default(color));      public color textcolor     {         { return (color)getvalue(textcolorproperty); }         set { setvalue(textcolorproperty, value); }     } } 

sample usage:

<!-- app/page resources --> <resourcedictionary>     <controltemplate x:key="threeborderbtn">         <grid rowspacing="0" columnspacing="0" margin="0">             <boxview margin="5" backgroundcolor="purple" />             <boxview margin="10" backgroundcolor="green" />             <boxview margin="15" backgroundcolor="red" />             <contentpresenter margin="20" />         </grid>     </controltemplate> </resourcedictionary>  <!-- control usage --> <!-- make sure register xmlns:local namespace -->  <local:templatedbutton      heightrequest="100"     text="button caption!"      textcolor="teal"      command="{binding clickcommand}"     backgroundcolor="white"     controltemplate="{staticresource threeborderbtn}" /> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -