开发者

how to reference a class defined inside the same page in silverlight

开发者 https://www.devze.com 2023-01-13 14:01 出处:网络
for example: I have: public class MyPage : X开发者_如何学PythonXXPage { ..... public class HahaConverter: IValueConverter

for example:

I have:

public class MyPage : X开发者_如何学PythonXXPage
{
.....

  public class HahaConverter: IValueConverter
{

.........

....
}

}

In my xaml, can I do this:

   <Page.Resources>
        <????:HahaConverter :Key="dateConverter" />
    <Page.Resources>

I just wondering how to get ????. I could not reference myself?

Thanks


Nested classes will require a fully qualified reference, so you will need to add another xmlns entry to the xaml referencing your parent class namespace. e.g.

xmlns:ValueConverters="clr-namespace:YourAppName.MyPage;assembly=YourAppName"

In VS 2010 once you start typing auto-complete/intellisense should start listing your project namespaces*.

Then reference your value converter with

<ValueConverters:HahaConverter x:Key="dateConverter">

*Note: It is usually recomended to stick to the one-class one-file standard as tools, coders (and VS) cope better. You will likely wind up with a large collection of Value Converters for Silverlight, might as well start a library for them :)

0

精彩评论

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