i'm trying create custom renderer progressbar can change color. classes below:
public class colorprogressbar : progressbar { public static bindableproperty barcolorproperty = bindableproperty.create( "barcolor", typeof( color ), typeof( progressbar ), constants.orange ); public color barcolor { { return (color)getvalue( barcolorproperty ); } set { setvalue( barcolorproperty, value ); } } }
then, in myapp.uwp project, have:
[assembly: exportrenderer (typeof(colorprogressbar), typeof(progressbarrenderer))] namespace myapp.uwp { public class colorprogressbarrenderer : progressbarrenderer { public colorprogressbarrenderer() {} protected override void onelementchanged( elementchangedeventargs<progressbar> e ) { base.onelementchanged( e ); if ( e.newelement == null ) return; if ( control != null ) updatebarcolor(); } protected override void onelementpropertychanged( object sender, propertychangedeventargs e ) { base.onelementpropertychanged( sender, e ); if ( e.propertyname == colorprogressbar.barcolorproperty.propertyname ) { updatebarcolor(); } } private void updatebarcolor() { var element = element colorprogressbar; var color = windows.ui.colorhelper.fromargb( (byte)255, (byte)247, (byte)137, (byte)30 ); var brush = new windows.ui.xaml.media.solidcolorbrush( color ); control.foreground = brush; } } }
however, error in subject line along cannot resolve assembly or windows metadata file 'system.xaml.dll'
when building. suspect has setting color , brush, i'm not sure how correct class otherwise.
i wanted change color :/
edit: added system.xaml.dll assembly, , error in app.xaml when building: object reference not set instance of object
. there conflict between xamarin , system.xaml.dll?
Comments
Post a Comment