Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Is this a Bug of WPF PropertyGrid? hope I was wrong
posted

I am implementing a WPF PropertyGrid  by using Infragistics XamPropertyGrid. However look there is an issue, the dropdown list for ColourType  and  CoreType display only Colours for select. CoreType should display Core1, Core2 and Core3, however Coretype now display  Colours Value. Anything Wrong?  

if I remove converter for Colour, then CoreType dropdown items display correct!!!! So I think this is a Bug of WPF PropertyGrid, hope I was wrong.

Please could anyone see all code for reproduce the issue following:

<Window x:Class="IGWpfApplication1.MainWindow"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="MainWindow" Height="522" Width="755" xmlns:ig="http://schemas.infragistics.com/xaml" Loaded="Window_Loaded">

<Grid>

<ig:XamPropertyGrid Margin="12,0,12,12" Name="xamPropertyGrid1" />

Grid>

Window>

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

namespace IGWpfApplication1

{

///

/// Interaction logic for MainWindow.xaml

///

public partial class MainWindow : Window

{

public MainWindow()

{

InitializeComponent();

}

private void Window_Loaded(object sender, RoutedEventArgs e)

{

DataClass data1 = new DataClass();

data1.TrueOrFalse = true;

data1.CoreType = "Core2";

data1.ColourType = "Green";

this.xamPropertyGrid1.SelectedObject = data1;

}

}

}

dataClass:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Linq;

using System.Text;

namespace IGWpfApplication1

{

public class DataClass

{

private bool _trueOrFalse = false;

private String _coreType = "";

private String _colourType = "";

public bool TrueOrFalse

{

get{return _trueOrFalse;}

set{_trueOrFalse = value;}

}

[TypeConverter(typeof(CoreTypeConverter))]

public String CoreType

{

get{return _coreType;}

set{_coreType = value;}

}

[TypeConverter(typeof(ColourTypeConverter))]

public String ColourType

{

get{return _colourType;}

set{_colourType = value;}

}

}

 

public class CoreTypeConverter : StringConverter

{

public override bool GetStandardValuesSupported(ITypeDescriptorContext context)

{return true;}

public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)

{return true;}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)

{

List<string> list = DemodataClass.GetCoreList();

return new StandardValuesCollection(list);

}

}

public class ColourTypeConverter : StringConverter

{

public override bool GetStandardValuesSupported(ITypeDescriptorContext context)

{return true;}

public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)

{return true;}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)

{

List<string> list = DemodataClass.GetColourList();

return new StandardValuesCollection(list);

}

}

public static class DemodataClass

{

// the following could return daynamic values from database.

private static List<string> CoreList = new List<string>() { "Core1", "Core2", "Core3" };

private static List<string> ColourList = new List<string>() { "Red", "Green", "Yellow" };

// the following could return daynamic values from database.

public static List<string> GetCoreList()

{

return CoreList;

}

// the following could return daynamic values from database.

public static List<string> GetColourList()

{

return ColourList;

}

}

This class works fine in Windows form Property grid.

Any one can help me out? Many thanks.  

Wpf PropertyGrid Issue Screenshot.zip