|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using WPFFormDesigner.WPFControlUtils;
namespace WPFFormDesigner.Converters
{
public class ListViewAddButtonConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
//ObservableCollectionItem oci = null;
Button btn = value as Button;
if(btn != null)
{
StackPanel sp = UIHelper.FindParent<StackPanel>(btn,false);
if(sp != null)
{
ListView lv = UIHelper.FindFirstChild<ListView>(sp,false);
if (lv != null)
{
Binding binding = BindingOperations.GetBinding(lv, ListView.ItemsSourceProperty);
if (binding != null)
{
//oci = new ObservableCollectionItem
// {
// BindingPath = binding.Path.Path,
// ListViewName = lv.Name
// };
//return oci;
return binding.Path.Path;
}
}
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Sr. application developer currently developing desktop and web applications for the specialty insurance sector. Data integration specialist, interested in learning the latest .Net technologies.