c# - WPF Custom Property -


i have added new property progresbar control, how ever don't think i'm doing correctly. below progressbar in mainwindow.xaml, need have 2 values gap between them.

<progressbar style="{staticresource circularprogress}"                  value="50"                 extensions:customextensions.radius="140 0" /> 

now here custom extension, made string there gap between 2 numbers.

public static readonly dependencyproperty radiusproperty =     dependencyproperty.registerattached("radius", typeof(string), typeof(customextensions), new propertymetadata(default(string)));  public static void setradius(uielement element, string value) {     element.setvalue(radiusproperty, value); }  public static string getradius(uielement element) {     return (string)element.getvalue(radiusproperty); } 

now here use custom property, isn't working.

<pathfigure x:name="pathfigure" startpoint="{binding path=radius, relativesource={relativesource templatedparent}}"> 

really have got 2 questions: 1. values don't seem applying controltemplate, if remove binding enter 140 0 myself shows arcsegment, binding doesn't.

  1. is possible type radius custom property without extensions:customextensions?

edit: when attempting bind textbox value error:

exception thrown: 'system.windows.markup.xamlparseexception' in presentationframework.dll

additional information: 'provide value on 'system.windows.baml2006.typeconvertermarkupextension' threw exception.' line number '36' , line position '20'.

code:

<progressbar style="{staticresource circularprogress}"                       value="{binding source={staticresource runtimevariables},path=uploadprogress}"                       extensions:customextensions.radius="80"                       name="test"/>         <textblock text="{binding elementname=test, path=(extensions:customextensions.radius)}"/> 

you must use special syntax if binding attached property (with parentheses around attached property). also, should specify converter convert string point.

here example:

<pathfigure x:name="pathfigure" startpoint="{binding path=(extensions:customextensions.radius), relativesource={relativesource templatedparent}, converter={staticresource pointconverter}"> 

edit: unable reproduce issue. use following code , text-block has correct output:

<progressbar extensions:customextensions.radius="80" name="test"/> <textblock text="{binding elementname=test, path=(extensions:customextensions.radius)}"/> 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -