Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Data;
- namespace WpfApp3.Converters
- {
- class TextSplitConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (targetType != typeof(string) || value == null)
- return null;
- var name = value.ToString().Split(' ');
- if (name.Length < 2)
- return null;
- if(int.TryParse(parameter.ToString(), out int index))
- return null;
- return name[index];
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement