List.Default.xaml not being applied

May 14, 2014 at 2:38 AM
I am working through the article on setting up the first CODE FW project. I created the view to hold the list of customers:
I am using this to bind to the Customers List and apply the template. The collection is being created ok.

<ListBox ItemsSource="{Binding Customers}" Style="{DynamicResource CustomerList}"/>

But when I run it, the list is just showing the list and displaying the name of the class in the collection.. its not applying the datatemplate style I have defined in List.Default.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType="ListBox" x:Key="CustomerList">
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Label Content="{Binding FirstName}" Width="200" />
                        <Rectangle Width="1" Stroke="Silver" />
                        <Label Content="{Binding LastName}" Width="200" />
                        <Rectangle Width="1" Stroke="Silver" />
                        <Label Content="{Binding Company}" Width="200" />
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
Anything I am missing in the FW setup here?
Thanks
Harold
Developer
May 14, 2014 at 1:15 PM
Edited May 14, 2014 at 1:15 PM
Hello Harold and welcome to the CODE Framework.

I suggest moving your style to the List.Layout.xaml file instead of the List.Default.xaml file. Off the top of my head I don't recall the origin of the .Default file, but I believe is it more or less just included for backward compatibility and not used in the current layouts.

Jeff
May 14, 2014 at 2:21 PM
ok, that seemed to work! the documentation stated List.default.xaml... might just be out of date, thanks very much!
Coordinator
May 14, 2014 at 7:45 PM
The x.default.xaml file gets loaded if there isn't a theme specific file (not even an empty one!). So if you are running with a theme called "MyTheme" but there isn't a List.MyTheme.xaml file at all, it will load List.Default.xaml. If there is a MyTheme file, it will load that instead and ignore Default.

The Layout file behaves different in that it ALWAYS gets loaded, regardless of whether there is a theme specific file.


Markus
May 15, 2014 at 1:40 AM
ok, thanks markus for the clarification.. still learning the work flow of CODE... but so far it's been awesome to work with. Doing my homework before next weeks' class!

harold