Unable to add ResourceDictionaries to AcropolisApplication.Resources

I want to include some resources at the application level like so:
<AcropolisApplication.Resources>
<Framework:ResourceDictionary>
<Framework:ResourceDictionary.MergedDictionaries>
<Framework:ResourceDictionary Source="/Resources/BrushResources.xaml"/>
</Framework:ResourceDictionary.MergedDictionaries>
</Framework:ResourceDictionary>
</AcropolisApplication.Resources>

But the compiler complains with the following message:

Error 20 The "MonikerCompileTask" task failed unexpectedly.
MS.Internal.Xaml.XamlException: Missing End Property Tag Line:11 Offset:4
at MS.Internal.Xaml.XamlException.Throw(XamlReaderContext ctx, String error)
at MS.Internal.Xaml.Parser.XamlParser.Parse_ENDTAG()
at MS.Internal.Xaml.Parser.XamlParser.P_PropertyCollection()
at MS.Internal.Xaml.Parser.XamlParser.ParseRule(Rule rule, Repeat repeat, String ruleName)
at MS.Internal.Xaml.Parser.XamlParser.P_Property()
at MS.Internal.Xaml.Parser.XamlParser.ParseRule(Rule rule, Repeat repeat, String ruleName)
at MS.Internal.Xaml.Parser.XamlParser.P_FullElement()
at MS.Internal.Xaml.Parser.XamlParser.ParseRule(Rule rule, Repeat repeat, String ruleName)
at MS.Internal.Xaml.Parser.XamlParser.P_Element()
at MS.Internal.Xaml.Parser.XamlParser.ParseRule(Rule rule, Repeat repeat, String ruleName)
at Microsoft.Acropolis.Design.XamlPropertyProvider.RegisterXaml(XmlReader xamlStream)
at Microsoft.Acropolis.Design.XamlPropertyProvider.Register(String fileName)
at Microsoft.Build.Tasks.Acropolis.MonikerCompileTask.RegisterFile(String fileName)
at Microsoft.Build.Tasks.Acropolis.MonikerCompileTask.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) Frontend

-
Any clue why?

Thanks,
Pavan

[1993 byte] By [PavanPodila] at [2008-3-6]
# 1
There are some resources (for eg. Brushes) that are used application-wide. In a typical WPF application I would have added it to the Application.Resources. Is there an equivalent on Acropolis ?

Thanks,
Pavan

PavanPodila at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 2

You should be able to add it to the Window1.xaml file. In the "AwxTongue Tiedhell" class.

KathyKam at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 3
Adding resources to a Window (or Shell) does not make it available throughout the Application but only within the context of the Window. I want certain resources to available application-wide across all Windows/components, etc. As I mentioned before, in a standard WPF application you would add it to Application.Resources. Is there an equivalent in Acropolis?

Thanks,
Pavan

PavanPodila at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 4

Hi All

My question is same, how to add Application Level ResourceDictionaries. Waiting for help asap.

Thanks

AllTec

AllTec at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 5

You can add a custom theme to your Acropolis Application and merge your resources into the theme:

XAML (note that I'm merging Acropolis theme into my custom theme, because I don't want to recreate all the theme from scratch).

Code Snippet

<acrowin:Theme x:Class="AcropolisApp23.MyCustomTheme"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:acrowin="clr-namespace:Microsoft.Acropolis.Windows;assembly=Microsoft.Acropolis.Windows"

xmlns:acrothemes="clr- namespace:Microsoft.Acropolis.Windows.Themes;assembly=Microsoft.Acropolis.Windows.Themes"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<acrowin:Theme.MergedDictionaries>

<acrothemes:AcropolisTheme/>

<</< FONT>acrowin:Theme.MergedDictionaries>

</acrowin:Theme>

Code-behind (include the call to InitializeComponent())

Code Snippet

using Microsoft.Acropolis.Windows;

namespace AcropolisApp23

{

public partial class MyCustomTheme : Theme

{

public MyCustomTheme()

{

InitializeComponent();

}

}

}

Register your theme in the Application constructor:

Code Snippet

public Application()

{

RegisterThemeAssembly(typeof(MyCustomTheme));

InitializeComponent();

}

And finally, specify your theme in the Applicationd definition:

Code Snippet

<AcropolisApplication x:Class="AcropolisApp23.Application"

......

Theme="AcropolisApp23.MyCustomTheme">....

AlexBulankou at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 6

Alex,

This is temporary solution for time now or it is going to be same as it is in future releases.

Thanks

AllTec

AllTec at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 7
AllTec wrote:

Alex,

This is temporary solution for time now or it is going to be same as it is in future releases.

Thanks

AllTec

In the future we are considering a new theme template that should simplify creation of the custom themes. However as of now the main concept is planned to remain the same.

We would appreciate if you could share your thoughts about this approach to custom theming.

Thanks!

AlexBulankou at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 8

Alex,

Reason for asking my question was my resource dictionaries have UI Styles, colors as well as application data (Typical resource dictionary of WPF app). This application data are DPs which I am using and updating throughout application kind of maintain current state of application.

If I create a theme with my application data (Styles as well), this business objects specific to this application will be unnecessary there in another application where I want to reuse this theme (Colors and Styles only).

This was the reason for asking this question. Please suggest and do let me know if you need more detail.

Thanks

AllTec

AllTec at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 9
AllTec wrote:

Alex,

Reason for asking my question was my resource dictionaries have UI Styles, colors as well as application data (Typical resource dictionary of WPF app). This application data are DPs which I am using and updating throughout application kind of maintain current state of application.

If I create a theme with my application data (Styles as well), this business objects specific to this application will be unnecessary there in another application where I want to reuse this theme (Colors and Styles only).

This was the reason for asking this question. Please suggest and do let me know if you need more detail.

Thanks

AllTec

Hi AllTec,

So, in your case I would create and apply a custom theme to maintain custom consistent UI appearance across your application. If you would like to merge a separate resource dictionary with your business objects, you still have an option to add it to the Application, but you need to do it from code-behind:

Code Snippet

public Application()

{

InitializeComponent();

ResourceDictionary dictionary = new ResourceDictionary();

dictionary.Source = new Uri("MyCustomDictionary.xaml", UriKind.Relative);

Resources.MergedDictionaries.Add(dictionary);

}

I hope this helps!

AlexBulankou at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 10

Yes,

That is smart solution.

Thanks for your help.

AllTec
AllTec at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...
# 11

Excuse me, what project item should I add to be able to paste XAML from 1st snippet and create .cs code-behind?

Romualds at 2007-10-2 > top of Msdn Tech,.NET Development,Acropolis...

.NET Development

Site Classified