Skip to main content

Microsoft Silverlight

Answered Question How to implement a simple type converter in Silverlight 2 Beta2RSS Feed

(0)

AccidenceSilverlight
Accidenc...

Member

Member

1 points

4 Posts

How to implement a simple type converter in Silverlight 2 Beta2

Hi,

I kown how to implement a simple type converter that provides a drop-down list of standard values in a property browser in WPF.

How do it in Silverlight 2 Beta2 ?

I use the namespace "System.ComponentModel" , but i can't find  method "GetStandardValuesSupported","StandardValuesCollection" to override!

逆水行舟,不尽则退

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: How to implement a simple type converter in Silverlight 2 Beta2

Hello, TypeConverter.GetStandardValuesSupported is usually used in Windows Forms data binding. In WPF and Silverlight, you create a class implements IValueConverter. You need to check the type in the converter's methods. Here's a simple sample:

public class NameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
MyObject myObj = value as MyObject;
if (myObj == null)
{
throw new Exception("Invalid Type!");
}
return myObj.FirstName + " " + myObj.LastName;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}

 

For StandardValuesCollection, I don't know what is it. Can you be more specific?

 

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

AccidenceSilverlight
Accidenc...

Member

Member

1 points

4 Posts

Answered Question

Re: How to implement a simple type converter in Silverlight 2 Beta2

Thank you!

 Using "Compile Conditionally" this method my problem was resolved.

 

逆水行舟,不尽则退
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities