簡體   English   中英

錯誤:System.Windows.Controls.UIElementCollection'不包含'OfType'的定義

[英]Error: System.Windows.Controls.UIElementCollection' does not contain a definition for 'OfType'

我想刪除WPF Canvas中的所有省略號。 我用這個方法:

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

我需要包含一些東西嗎?....

是的,你需要包括System.Linq命名空間為解釋在這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM