This is a migrated thread and some comments may be shown as answers.

Strange error if I set the SelectionChanged event

1 Answer 107 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Pinho
Top achievements
Rank 1
Pinho asked on 16 Mar 2009, 06:59 PM
Hi telerik experts,

 I'm using the telelik combobox with the data bind to an ObservableCollection of a custom object.

 Basically, this combo is used to show an image with the flag and respective country code to allow the user to change the language of the application.

 So, I have got the following helpers:

 The cultureInfoItem class, that stores the infoID and the respective flag image

    public class CultureInfoItem : INotifyPropertyChanged, IEquatable<CultureInfoItem> 
    { 
        private string cultureInfoID; 
 
        public string CultureInfoID 
        { 
            get { return cultureInfoID; } 
            set 
            { 
                cultureInfoID = value
                if (PropertyChanged != null) 
                    PropertyChanged(this, new PropertyChangedEventArgs("CultureInfoID")); 
            } 
        } 
        private string cultureInfoFlag; 
 
        public string CultureInfoFlag 
        { 
            get { return cultureInfoFlag; } 
            set 
            { 
                cultureInfoFlag = value
                if (PropertyChanged != null) 
                    PropertyChanged(this, new PropertyChangedEventArgs("CultureInfoFlag")); 
            } 
        } 
 
        public CultureInfoItem(string cultureID) 
        { 
            CultureInfoID = cultureID
            CultureInfoFlag = string.Format("/SilverlightStatusBarTesting;component/Images/Flags/{0}.png", cultureID); 
        } 

The combobox is binded to:
internal ObservableCollection<CultureInfoItem> cultureInfoCollection; 

So, I add, remove, edit the items and the combo box is always updated. This works fine.

Then the xaml part, the combo box is defined in the following way:

        <telerikInput:RadComboBox x:Name="cmbCultureSelection" HorizontalAlignment="Center" VerticalAlignment="Center" Width="50" Height="22" Margin="2,2,2,2" Opacity="0.80" Grid.Row="1" Grid.Column="3"
            <telerikInput:RadComboBox.ItemTemplate> 
                <DataTemplate> 
                    <StackPanel Orientation="Horizontal"
                        <Image Source="{Binding Path=CultureInfoFlag}" Height="11" Margin="2,2,2,2"/> 
                        <TextBlock Text="{Binding Path=CultureInfoID}" FontFamily="Verdana" FontSize="9" VerticalAlignment="Center" /> 
                    </StackPanel> 
                </DataTemplate> 
            </telerikInput:RadComboBox.ItemTemplate> 
        </telerikInput:RadComboBox> 

When I set the callback to take care of the SelectionChanged event, it doesn't even load the web page:

SelectionChanged="cmbCultureSelection_SelectionChanged" 

Afterwards:

        <telerikInput:RadComboBox x:Name="cmbCultureSelection" HorizontalAlignment="Center" VerticalAlignment="Center" Width="50" Height="22" Margin="2,2,2,2" Opacity="0.80" Grid.Row="1" Grid.Column="3" SelectionChanged="cmbCultureSelection_SelectionChanged"
            <telerikInput:RadComboBox.ItemTemplate> 
                <DataTemplate> 
                    <StackPanel Orientation="Horizontal"
                        <Image Source="{Binding Path=CultureInfoFlag}" Height="11" Margin="2,2,2,2"/> 
                        <TextBlock Text="{Binding Path=CultureInfoID}" FontFamily="Verdana" FontSize="9" VerticalAlignment="Center" /> 
                    </StackPanel> 
                </DataTemplate> 
            </telerikInput:RadComboBox.ItemTemplate> 
        </telerikInput:RadComboBox> 

Code-behind:
private void cmbCultureSelection_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e) 
 

Error:

Unhandled error in Silverlight 2 Application 
AG_E_PARSER_BAD_PROPERTY_VALUE (Line:54 Position: 221) 

The line and position points to SelectionChanged="cmbCultureSelection_SelectionChanged"

What am I doing wrong?

Thanks for all the help,

Luís Miguel Pinho

P.S.: I'm using version Q1 2009

1 Answer, 1 is accepted

Sort by
0
Pinho
Top achievements
Rank 1
answered on 17 Mar 2009, 10:47 AM
Sorry for replying to myself

I removed the combo box, created a new one with a diferent name but the same content and now, I don't get any error....

This is strange, but since it works, I would not waste time trying to figure out what went wrong...
Tags
ComboBox
Asked by
Pinho
Top achievements
Rank 1
Answers by
Pinho
Top achievements
Rank 1
Share this question
or