Issues with the namespace xmlns:extra="http://schemas.extra.com/ui"?

May 30, 2014 at 5:25 AM
Edited May 30, 2014 at 9:19 AM
First of all my high appreciation for the framework!

However, I'm experiencing a failure I cannot find a solution for and asking for help.
First of all my setup:
  • Visual Studio 2013
  • Elysium and Elysium Extra as NuGet-Package as available as of 30.05.2014
I followed the instructions in the "Getting started" section and controls like TabControl, etc. work fine! However, as soon as I want to use controls using the extra-namespace /xmlns:extra="http://schemas.extra.com/ui"), I'm experiencing issues.

If I try to use <extra:Accordion> nothing is rendered. I managed to work-around adding the following source to my UserControl:
<UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Framework.UI;component/Themes/ElysiumExtra/Accordion.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
although I saw that this xaml is included already in General.xaml which is included in my Apps.xaml. So far so good - for extra:Accordion this workaround did the job.

I tried the same workaround for the DataGrid as well - as long as I do only use WPF-Controls, everything works fine:
<DataGrid x:Name="symbolDataGrid" Grid.Row="1" 
                  RowDetailsVisibilityMode="VisibleWhenSelected" 
                  ItemsSource="{Binding}" 
                  EnableRowVirtualization="True" 
                  AutoGenerateColumns="False"
                  DataContext="{StaticResource symbolViewSource}">

            <DataGrid.Columns>
                <DataGridTextColumn x:Name="nameColumn" 
                                    Width="Auto" 
                                    Header="Langbezeichnung" 
                                    Binding="{Binding Name}"/>
            </DataGrid.Columns>
        </DataGrid>
As soon as I add the "extra:" before the DataGridTextColumn (pls see the code sniplet below), the compiler gives the error "ResourceReferenceKeyNotFoundException - DataGridTextColumnEditingElementStyle". The error also says it was raised by Framework.UI.Controls.DataGridTextColumn.
I saw it is defined in DataGrid.xaml but for whatever reason, it is not found - even if I explicitly add it the same way as I did with the Accordion.... just with <ResourceDictionary Source="/Framework.UI;component/Themes/WPF/Controls/DataGrid.xaml"/>
<DataGrid x:Name="symbolDataGrid" Grid.Row="1" 
                  RowDetailsVisibilityMode="VisibleWhenSelected" 
                  ItemsSource="{Binding}" 
                  EnableRowVirtualization="True" 
                  AutoGenerateColumns="False"
                  DataContext="{StaticResource symbolViewSource}">

            <DataGrid.Columns>
                <extra:DataGridTextColumn x:Name="nameColumn" 
                                    Width="Auto" 
                                    Header="Langbezeichnung" 
                                    Binding="{Binding Name}"/>
            </DataGrid.Columns>
        </DataGrid>
However there seems to be an issue between the "extra:" namespace and rendering of data. Any help on this is highly appreciated!!!

Regards, Markus
Coordinator
May 30, 2014 at 3:43 PM
Edited May 30, 2014 at 3:44 PM
Hi,

This all sounds very strange. You only need to add the Elysium Extra Generic.xaml reference to your App.xaml file in your project and nothing else. You should not need to do any work arounds.
<Application x:Class="WpfApplication1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Framework.UI;component/Themes/Generic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
My advice would be to start out with a new blank WPF project and follow the steps in the Getting Started section in the Documentation tab on this website. I just followed the steps myself and checked that they do indeed work and I haven't missed anything. I even added an Accordion control:
<extra:Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:extra="http://schemas.extra.com/ui"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <extra:Accordion>
            <extra:AccordionItem Content="Hello" Header="Hello"/>
            <extra:AccordionItem Content="World" Header="World"/>
        </extra:Accordion>
    </Grid>
</extra:Window>
I hope that helps. If you like the framework, please rate it on the front page.
Jun 1, 2014 at 8:51 AM
Dear rehansaeed,

thank you very much for the immediate reply.
There seems to be a bug in Microsoft Visual Studio, which causes problems when merging resource-dictonaries - the workaround is to put an "empty" style to the resource dictionary like this (for details pls check http://stackoverflow.com/questions/17057934/wpf-merged-resource-dictionary-no-being-recognized-from-app-xaml):
<Application x:Class="TradingJournal.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:metro="http://schemas.codeplex.com/elysium"
             xmlns:params="http://schemas.codeplex.com/elysium/params"
             xmlns:extra="http://schemas.extra.com/ui"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Framework.UI;component/Themes/Generic.xaml"/>
                <ResourceDictionary Source="Resources\ABCStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="{x:Type Rectangle}"/>
        </ResourceDictionary>
    </Application.Resources>
</Application>
Regards, Markus
Coordinator
Jun 3, 2014 at 9:13 AM
Hi Markus,

Thats a very interesting problem that I've not come across before. Is this happening because you are merging an additional resource dictionary?

I'm glad this hack worked for you though, perhaps we can put something in Elysium Extra to solve this problem.
Jun 3, 2014 at 9:18 AM
Edited Jun 3, 2014 at 9:20 AM
Hi rehansaeed,

this seems to be the case - I've found a lot of hints in the web claiming that this seems to be a bug when merging ResourceDictionaries. However - the workaround is pretty simple and I do need to merge dictionaries as I have some personal styles as well... I'm not sure if you can implement a workaround on your side because it needs to be done at the level where the dictionaries are merged - which would normally be outside of your library.

However - maybe a simple hint in the documentation section would already solve most of the issues.
Thanks & regards, Markus