0

I am trying to write a DataTemplate for a class Examination_Room. In this class there is a list, containing enum values called Examination_type. I tried to do this by using ItemsControl and giving the list as ItemsSource, but I am failing to implement the enum value(see code below.

Class:

class Examination_Room : Room
{
    public int id { get; set; }
    public string name { get; set; }
    public List<Examination_Types> types { get; set; }
    public List<Waiting_Room> possible_Waiting_Rooms { get; }
}

Enum:

public enum Examination_Types
{
    CR,
    CT,
    MG,
    MR,
    NM,
    OT,
    US,
    USM
}

DataTemplate so far:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:CAS_KAO">
<DataTemplate DataType="{x:Type local:Examination_Room}">
    <Border x:Name="examination_room" Margin="10" BorderBrush="Black" BorderThickness="2">
        <StackPanel Orientation="Vertical">
            <StackPanel Margin="5" Orientation="Horizontal">
                <TextBlock  FontSize="20" FontWeight="Bold" Text="Examination room: "/>
                <TextBlock  FontSize="20" FontWeight="Bold" Name="room_name" Text="{Binding name}"/>
            </StackPanel>
            <Separator/>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Examination Types: "/>
                <ItemsControl ItemsSource="{Binding types}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding *****}"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </StackPanel>
    </Border>
</DataTemplate>

This is my solution so far, but as you can see in the code, marked with the 5 stars, I don't know how to access the enum's value. (note: As of right now the data template was only tested without the whole examination type thing)

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • just `"{Binding}"`, without any path. or remove `` completely and result will be same: ItemsControl will show names of enum fields – ASh Jul 10 '18 at 11:13
  • Thank you worked perfectly! –  Jul 10 '18 at 11:25

0 Answers0