开发者

Access private members in Silverlight

I am pretty new to Silverlight but I see this being done all the time. I just don't know yet how to do it.

How do I access functionality of a private member?

First of all, I got a runtime error when trying to use the Busy Window Indicator when a seperate thread called the window code associated with the BusyIndicator.

Anyway, so my solution 开发者_运维百科was to try to make this call as public as possible. But now I am getting a compile error. Can someone help me with this?

Please suggest how I can get past this error message.

Access private members in Silverlight


It's not a private member issue - BusyWindow is an instance member, i.e. associated with an instance of the containing class. Your setbusywindow property is a static member, i.e. associated with the type itself. If there are multiple instances of your class (or none) which instance would you expect to fetch the BusyWindow property from?

You need to learn about the static keyword and its meaning in various contexts.

Note that currently your BusyWindow field is public, which is generally a really bad idea.


For this to work the way you've done it, either BusyWindow needs instantiating or IsBusy needs to be made static.

public static bool IsBusy{get;set;}

This is because you're trying to access an instance member asif it's a static member.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜