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
490
xamGrid ComboBoxColumn value not displayed. Selecting an item results in XamlParseException
posted

Problem 1: In the following code I expect the grid to display the value "Digital" in the ComboBoxColumn of the first row. Instead, I have an empty cell.

Problem 2: When I select "Digital" and tab out from the cell I receive the exception at the bottom.

public class ResourceTypes : ObservableCollection

{
public ResourceTypes()
{
this.Add(new ResourceTypeElement {Name = "Printed"});
this.Add(new ResourceTypeElement {Name = "Digital"});
}
}

public class ResourceTypeElement : INotifyPropertyChanged
{
private string name;
public string Name
{
get
{
return this.name;
}
set
{
if (this.name != value)
{
this.name = value;
}
}
}

public event PropertyChangedEventHandler PropertyChanged;
}

public class Resource: INotifyPropertyChanged
{
public ResourceTypeElement Type { get; set; }

public Resource()
{
this.Type = new ResourceTypeElement { Name = "Digital" };
}

public event PropertyChangedEventHandler PropertyChanged;
}

public class ResourceDetailViewModel
{
public ObservableCollection Resources { get; set; }

public ResourceDetailViewModel()
{
this.Resources = new ObservableCollection;
this.Resources.Add(new Resource());
}

}
Xaml:

AutoGenerateColumns="false"
ColumnWidth="*">

IsEnterKeyEditingEnabled="True"
IsF2EditingEnabled="True"
IsMouseActionEditingEnabled="SingleClick"
IsOnCellActiveEditingEnabled="True" />


ItemsSource="{Binding Source={StaticResource ResourceTypes}}"
SelectedValuePath="Name"
DisplayMemberPath="Name"
AllowEditingValidation="False"/>







The exception I receive when I select a combo box item and tab out:

System.Windows.Markup.XamlParseException occurred
Message= [Line: 0 Position: 0]
LineNumber=0
LinePosition=0
StackTrace:
by MS.Internal.XcpImports.CheckHResult(UInt32 hr)
InnerException: System.Collections.Generic.KeyNotFoundException
Message=The given key was not present in the dictionary.
StackTrace:
by System.Collections.Generic.Dictionary`2.get_Item(TKey key)
by System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri, Type componentType)
InnerException:

Parents
No Data
Reply Children
No Data