开发者

WP7 Binding to Local Variable

I have 开发者_JAVA百科a UI element whose color I'd like to set based on a local variable in the page (well actually in a module, but I can move it to the page).

I see in WPF one can bind a UI element to a local variable by making the variable a property and setting the binding RelativeSource to the parent class using FindAncestor:

WPF Binding to local variable

Unfortunately Silverlight doesn't seem to support FindAncestor mode.

Any possible solution, or do I have to create an instance of a custom class and such just for this one variable?


Ive been jumping from Silverlight to WPF a lot over the last few weeks, so the following idea may or may not fly.

Does your page have the name property set on it? If not, set it (x:Name="MyPage").

then you can do:

Fill="{Binding ElementName=MyPage, Path=MyProperty}"

Give that a try (just off the top of my head)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜