Windows phone 7 get form proterty`无法显式调用运算符或访问器`
我正在为wp7制作一个小应用程序,当我试图从引用中获取时,出现了一个错误 类似以下内容的代码: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())
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