c# - changing custom control textblock value by code -



c# - changing custom control textblock value by code -

i learning how write windows 8 app, , can't find answers problem.

i created custom command adding button click with:

onclick() { card currentcard = new card(); ... ... hand.children.add(currentcard); }

in page.cs

the current card command has generic.xaml info looks containing textblock

<style targettype="local:tile"> <setter property="verticalalignment" value="center"/> <setter property="template"> <setter.value> <controltemplate targettype="local:tile"> <border background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}"> <textblock x:name="label"/> // <----------------------- textblock </border> </controltemplate> </setter.value> </setter> </style>

what can in page.cs or perhaps card.cs get/set value of textblock named label?

sorry if simple or answered somewhere before, did searches, didn't find answer!

because textblock in question part of controltemplate custom type called tile, best bet add together dependencyproperty tile type , utilize templatebinding bind text property of textblock value of new dependencyproperty.

you cannot reach controltemplate outside modify value of part of template.

this answer provides 1 illustration of using dependencyproperty , binding controltemplate, , quick search yield many other examples.

c# xaml windows-store-apps controltemplate

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -