I'm converting a Silverlight app to WPF. The following piece of code didn't compile but it does in Silverlight:
XAML:
<Grid x:Name="Table">
</Grid>
Code behind:
foreach (var uiElement in Table.Children
.Where(x => Grid.GetColumn((Border)x) == Table.ColumnDefinitions.Count() - 1))
{
//do something
}
At Where
it says
'UIElementCollection' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'UIElementCollection' could be found (are you missing a using directive or an assembly reference?)
System.Linq
namespace is added.
If I cast UIElementCollection
to an IList<object>
then it works, but I receive a warning:
it's a suspicious cast
What am I doing wrong?