So I have the following scenario:
I have a class part of a view model as follows:
public class ResourceModuleAccess
{
public class ModuleAccess
{
ResourceModule module;
Mode mode;
}
public List<DisplayAccess> Items
{
get
{
var result = from g in groups
join p in groupAccess on g.GroupID equals p.GroupId into outer
from p in outer.DefaultIfEmpty()
select new DisplayAccess { Name = g.Name, Module = (p == null) ? ResourceModule.None : p.Module };
var output = result.ToList();
return output;
}
}
and I am trying to databind the items to a listbox to display the name and module
<ListBox ItemsSource="{Binding ModulesAccess.Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding DisplayAccess.Name}"></Label>
<CheckBox></CheckBox>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The listbox correctly displays for items, so it found the collection, but it is not able to map the properties to the label
I also tried
<DataTemplate DataType="{x:Type DisplayAccess}">
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}"></Label>
<CheckBox></CheckBox>
</StackPanel>
</DataTemplate>
but that doesn't build: it says it cannot find the public type DisplayAccess.