Windows phone 7 get form proterty`无法显式调用运算符或访问器`

Windows phone 7 get form proterty`无法显式调用运算符或访问器`,windows-phone-7,Windows Phone 7,我正在为wp7制作一个小应用程序,当我试图从引用中获取时,出现了一个错误 类似以下内容的代码: private void refreshExistingShellTile() { using (IEnumerator<ShellTile> enumerator = ShellTile.get_ActiveTiles().GetEnumerator()) { while (enumerator.MoveNext())

我正在为wp7制作一个小应用程序,当我试图从引用中获取时,出现了一个错误

类似以下内容的代码:

   private void refreshExistingShellTile()
    {
        using (IEnumerator<ShellTile> enumerator = ShellTile.get_ActiveTiles().GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                ShellTile current = enumerator.get_Current();
                if (null != current.get_NavigationUri() && !current.get_NavigationUri().ToString().Equals("/"))
                {
                    Black_n_Gold.Entities.Tile tile = App.CurrentApp.tileService.findById(App.CurrentApp.tileService.getTileId(current.get_NavigationUri().ToString()));
                    if (tile != null && tile.id == this.customizedTile.id)
                    {
                        current.Delete();
                        this.createShellTile(this.customizedTile);
                    }
                }
            }
        }
    } 
private void refreshExistingShellTile()
{
使用(IEnumerator枚举器=ShellTile.get_ActiveTiles().GetEnumerator())
{
while(枚举数.MoveNext())
{
ShellTile current=枚举数。获取当前值();
if(null!=current.get_NavigationUri()&&!current.get_NavigationUri().ToString().Equals(“/”)
{
Black_n_Gold.Entities.Tile Tile=App.CurrentApp.tileService.findById(App.CurrentApp.tileService.getTileId(current.get_NavigationUri().ToString());
if(tile!=null&&tile.id==this.customizedFile.id)
{
current.Delete();
this.createShellTile(this.customizedFile);
}
}
}
}
} 
我有这样的错误:

'Microsoft.Phone.Shell.ShellTile.ActiveTiles.get': cannot explicitly call operator or accessor
'Microsoft.Phone.Shell.ShellTile.NavigationUri.get': cannot explicitly call operator or accessor
'System.Collections.Generic.IEnumerator<Microsoft.Phone.Shell.ShellTile>.Current.get': cannot explicitly call operator or accessor
“Microsoft.Phone.Shell.ShellTile.ActiveTiles.get”:无法显式调用操作员或访问者
“Microsoft.Phone.Shell.ShellTile.NavigationUri.get”:无法显式调用运算符或访问器
“System.Collections.Generic.IEnumerator.Current.get”:无法显式调用运算符或访问器

当我尝试添加属性或从属性设置属性时,我遇到了相同的错误,我在web上查找,但找不到解决方案。

您使用的是底层方法名称。与此相反:

ShellTile current = enumerator.get_Current();
你想要:

ShellTile current = enumerator.Current;
但是,我还建议使用
foreach
循环,而不是显式调用
GetEnumerator
etc:

private void refreshExistingShellTile()
{
    foreach (ShellTile current in ShellTile.ActiveTiles)
    {
        Uri uri = current.NavigationUri;
        if (uri != null && uri.ToString() != "/")
        {
            Black_n_Gold.Entities.Tile tile = App.CurrentApp.tileService
                .findById(App.CurrentApp.tileService.getTileId(uri.ToString());
            if (tile != null && tile.id == customizedTile.id)
            {
                current.Delete();
                createShellTile(customizedTile);
            }
        }
    }
}
还请注意,.NET命名约定建议使用
findById
etc:

  • FindById
  • GetTileId
  • CreateShellTile

成功了,谢谢。。。我将尝试使用GetEnumerator获取所有代码,看看是否还有其他代码error@SebastiánMiles:您是如何开始编写此代码的?它是从某个地方反编译的吗?我对反编译的代码有这个问题,ILSpy反编译程序给了我“Vector3.get_zero();”,而Reflector反编译程序给了我“Vector3.zero;”—这很有效。@psychobrm:是的,在IL中它会显示为一个带有元数据的方法,以表明该方法是属性的获取者。