Sic03-8inch/SicUI/Models/RecipeEditors/Converters/RecipeStepsCollectionToSele...

33 lines
836 B
C#

using System;
using System.Collections;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using RecipeEditorLib.RecipeModel.Params;
namespace SicUI.Models.RecipeEditors
{
internal 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;
}
}
}