【问题标题】:Error: System.Windows.Controls.UIElementCollection' does not contain a definition for 'OfType'错误:System.Windows.Controls.UIElementCollection' 不包含 'OfType' 的定义
【发布时间】:2015-07-27 13:02:02
【问题描述】:

我想从 WPF 画布中删除所有省略号。我用了这个方法:

public void clearCircle()
{
    var circles = cvsSurface.Children.OfType<Ellipse>().ToList();
    foreach (var c in circles)
    {
        cvsSurface.Children.Remove(c);
    }
}

但是,我在 .OfType 上遇到错误:

'System.Windows.Controls.UIElementCollection' does not contain a definition for 'OfType' and no extension method 'OfType' accepting a first argument of type 'System.Windows.Controls.UIElementCollection' could be found.

我需要包含一些东西吗?我正在使用 .NET 4.5

【问题讨论】:

    标签: c# wpf canvas


    【解决方案1】:

    我需要包含一些东西吗?....

    是的,您需要按照here 的说明包含System.Linq 命名空间。

    【讨论】:

      猜你喜欢
      • 2018-12-25
      • 1970-01-01
      • 1970-01-01
      • 2019-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-05
      相关资源
      最近更新 更多