Sic.Framework-Nanjing-Baishi/MECF.Framework.UI.Client/CenterViews/Editors/Converters/RecipeStepsCollectionToSele...

33 lines
863 B
C#

using System;
using System.Collections;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using RecipeEditorLib.RecipeModel.Params;
namespace MECF.Framework.UI.Client.CenterViews.Editors.Converters
{
public class RecipeStepsCollectionToSelectedItemsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is RecipeStepCollection coll)
return coll.ToList();
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is IList list)
{
return new RecipeStepCollection(list.Cast<RecipeStep>());
}
return null;
}
}
}