SilverLight 问题解决

编写一个小的Silverlight控件,需要加入一个可写属性:

public string ReginName 
      { 
          
set { txtRegionName.Text = value; } 
      }

编译程序报错信息如下:

Error    1    The property 'ReginName' does not exist on the type 'RegionInfo' in the XML namespace 'clr-namespace:MderRegionApp.UserControls'.    D:\Code\MderRegionApp\MderRegionApp\UserControls\Map.xaml    17    23    MderRegionApp

网上找到的回答是在引用后面加入assembly,如下:

xmlns:profman="clr-namespace:SmartPinLib.ProfileManager;assembly=SmartPinLib

但这只是针对与引用不同的类库时有效,想到原来看的文章

《一步一步学Silverlight 2系列(2):基本控件》http://www.cnblogs.com/Terrylee/archive/2008/03/07/Silverlight2-step-by-step-part2.html

中的例子自己也做过没有出现这种情况,对比代码。。。。。,没想到在Silverlight当中属性要成对写:(

public string ReginName 
      { 
          
getreturn txtRegionName.Text;}
          
set { txtRegionName.Text = value; } 
      }

世界恢复平静,如果有兄弟也报这种错的话,可以参考。

原文地址:https://www.cnblogs.com/forrestsun/p/1425929.html