Using string [] in XAML
You can create a keyword property in XAML as follows:
<MyControl ...>
<MyControl.Keywords>
<sys:String>Happy</sys:String>
<sys:String>Sad</sys:String>
<sys:String>Angry</sys:String>
</MyControl.Keywords>
</MyControl>
Note. This involves declaring a namespace
xmlns:sys="clr-namespace:System;assembly=mscorlib"
ItemsControl :
<ListBox ItemsSource="{Binding Keywords}" ...>
ListBox.
[] WPF , ( , ). , .
, ObservableCollection . CLR- ( ) . XAML , , .
, , ObservableCollection. , , INotifyCollectionChanged.
XAML
. XAML , Keyword, , ObservableCollection .
IValueConverter
IValueConverter , , [], :
<TextBox Text="{Binding Keywords,
Converter={x:Static my:CommaSeparatedConverter.Instance}}" />
:
public class CommaSeparatedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return string.Join(",", (string[])value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return ((string)value).Split(',');
}
}