Programatic access to Resources and Beta 2 [Resources.Count = 0?]
hello everyone, hope i'm not repeating question...
i trying access resources of element in code behind of silverlight application. ultimate goal able load snippet of xaml , iterate through it's resources see if contains storyboards etc. in other words, not know actual names of resources @ time xaml loaded, , want still access these resources if exist through c# code.
in trying this, whenever checked frameworkelement.resources.count property 0. tried checking right after loaded xaml, after added new xaml layoutroot, , again after triggered mouse event. every time read count = 0. figured there may issue loading xaml local resources set [ie. <rectangle.resources .../>] tried set resources on usercontrol itself. again, left getting resources.count = 0 when page loaded.
i had friend of mine had not upgraded beta 2 run same code, , received resources.count = 1 on page load when both resource set locally on element, , when set on usercontrol itself... i'm guessing has changed between beta 1 , 2... can't seem figure out what, or if bug.
code:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wrappanel="clr-namespace:wrappanelext;assembly=graphics4"
xmlns:local="clr-namespace:graphics4;assembly=graphics4"
width="1000" height="700">
<storyboard x:name="myanimatedrectangle_storyboard">
<doubleanimation
storyboard.targetname="myanimatedrectangle"
storyboard.targetproperty="opacity"
from="1.0" to="0.0" duration="0:0:1"
autoreverse="true" repeatbehavior="forever" />
</storyboard>
</usercontrol.resources>
...
<rectangle x:name="myanimatedrectangle" width="50" height="50" fill="red" />
now in cs page have following code check resources.count property. notice when page loaded not indicate there resource on control, when add 1 manually , check, seems have registered newly created resource...
[in graphics4.page class]
{
int testcount = this.resources.count; // <== 0 [should 1?]
newsb.setvalue(frameworkelement.nameproperty, "testingnewsb");
has seen before? i'm @ impasse because not know if there resources on given snippet of xaml , have able iterate through them programatically.
thank you,
shayla
my apologies, after posting did little digging , found other people have brought issue up:
http://silverlight.net/forums/p/18734/64429.aspx#64429
seems known bug beta 2.
Silverlight > Programming Silverlight with .NET – General
Comments
Post a Comment