我如何将数据IEnumerable
与IsolatedStorage
. 这是我的代码:
var data1 = from query in document.Descendants("Services")
select new Ser
{
name = query.Element("Name") != null
? query.Element("Name").Value
: string.Empty,
};
ReportList.ItemsSource = data1;
// ...
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
try
{
string IsoKey = (((sender as MenuItem).DataContext) as Ser).name;
_isoSettings.Add(IsoKey, IsoKey);
_isoSettings.Save();
}
catch (ArgumentException)
{
MessageBox.Show("Эта служба уже в исключениях");
}
}
XAML:
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="Ignore" Click="MenuItem_Click" />
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<TextBlock Text="{Binding name}" Foreground="Coral" />
和:
foreach (string keyCollect in keysCollect)
{
returtStr += keyCollect;
}
我想将 data1 与 returtStr 进行比较。并且不要在 ListBox 中显示相同的数据。像这样的东西:
var comparedata = data1.Except(returtStr);
但我有一个错误:
错误 2 'System.Collections.Generic.IEnumerable' 不包含 'Except' 的定义和最佳扩展方法重载 'System.Linq.Queryable.Except(System.Linq.IQueryable, System.Collections.Generic.IEnumerable)'有一些无效参数 C:\Users\gromov\SkyDrive\Server Monitor\Server Monitor\MainPage.xaml.cs 143 29 Server Monitor
和:
错误 1 实例参数:无法从 'System.Collections.Generic.IEnumerable' 转换为 'System.Linq.IQueryable' C:\Users\gromov\SkyDrive\Server Monitor\Server Monitor\MainPage.xaml.cs 143 29 Server Monitor