Unable to use XAML player
Hello, I have started working on my gui using expression blend however I am having a problem when using the noesis xaml player, I am getting an error when attempting to run my .xaml files.
The error

MainWindow.xaml
Resources.xaml
App.xaml
I can however get the window to display by removing the errornous x:Class="VitareGraphicInterface.MainWindow" however this causes the window to become black and no elements are displayed.
Any help would be appreciated!
Cheers,
Matt
The error

MainWindow.xaml
Code: Select all
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="VitareGraphicInterface.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Grid x:Name="LayoutRoot">
<Button Content="Button" HorizontalAlignment="Right" Height="40" Margin="0,0,8,8" VerticalAlignment="Bottom" Width="128" Style="{DynamicResource LoginButton}"/>
<TextBox Height="39" Margin="18,0,153,9" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Bottom" Style="{DynamicResource passwordBox}"/>
</Grid>
</Window>
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="LoginButton" TargetType="{x:Type Button}">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFB7EAFF" Offset="0"/>
<GradientStop Color="#FF97D5EF" Offset="0.514"/>
<GradientStop Color="#FF97D5EF" Offset="1"/>
<GradientStop Color="#FFB7EAFF" Offset="0.498"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="passwordBox" TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="#FFCCA314"/>
</Style>
<!-- Resource dictionary entries should be defined here. -->
</ResourceDictionary>
Code: Select all
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="VitareGraphicInterface.App"
StartupUri="MainWindow.xaml">
<Application.Resources>
<!-- Resources scoped at the Application level should be defined here. -->
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Any help would be appreciated!
Cheers,
Matt
-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: Unable to use XAML player
Hi Mattiemus,
When you design an application with Expression Blend, the tool creates automatically an App.xaml and MainWindow.xaml that are binded to code behind classes, specified by the x:Class property. So if you don't remove that property, you should provide corresponding classes in C++.
For your example, you should create an Application derived class that defines the TypeId metadata with the value "VitareGraphicInterface.App" as it appears in the App.xaml:
You should also create a Window derived class that defines the TypeId metadata with the value "VitareGraphicInterface.MainWindow" as it appears in the MainWindow.xaml:
And finally, register those components in the ComponentFactory so NoesisGUI framework knows how to create them:
When you design an application with Expression Blend, the tool creates automatically an App.xaml and MainWindow.xaml that are binded to code behind classes, specified by the x:Class property. So if you don't remove that property, you should provide corresponding classes in C++.
For your example, you should create an Application derived class that defines the TypeId metadata with the value "VitareGraphicInterface.App" as it appears in the App.xaml:
Code: Select all
#include <NsGui/Application.h>
#include <NsCore/TypeId.h>
#include <NsCore/ReflectionImplement.h>
class VitareApp: public Noesis::Gui::Application
{
NS_IMPLEMENT_INLINE_REFLECTION(VitareApp, Noesis::Gui::Application)
{
NsMeta<Noesis::Core::TypeId>("VitareGraphicInterface.App");
}
};
Code: Select all
#include <NsGui/Window.h>
#include <NsCore/TypeId.h>
#include <NsCore/ReflectionImplement.h>
class VitareMainWindow: public Noesis::Gui::Window
{
NS_IMPLEMENT_REFLECTION(VitareMainWindow, Noesis::Gui::Window)
{
NsMeta<Noesis::Core::TypeId>("VitareGraphicInterface.MainWindow");
}
};
Code: Select all
#include <NsCore/Package.h>
#include "VitareApp.h"
#include "VitareMainWindow.h"
NS_REGISTER_REFLECTION(Vitare, GraphicInterface)
{
NS_REGISTER_COMPONENT(VitareApp)
NS_REGISTER_COMPONENT(VitareMainWindow)
}
NS_INIT_PACKAGE(Vitare, GraphicInterface)
{
}
NS_SHUTDOWN_PACKAGE(Vitare, GraphicInterface)
{
}
Re: Unable to use XAML player
By the way, these steps are fully described in the Tutorial 5: Building an application that comes with the NoesisGUI SDK.
Thanks.
Thanks.
Re: Unable to use XAML player
Thanks for the fast reply,
I have managed to get it working now, however it appears that the window was still appearing black as I was referencing styles (Style="{DynamicResource LoginButton}") in the window.
I have managed to get it working now, however it appears that the window was still appearing black as I was referencing styles (Style="{DynamicResource LoginButton}") in the window.
-
- michael1220
- Posts: 3
- Joined:
- Location: Vienna
Re: Unable to use XAML player
Where are the Tutorials located?By the way, these steps are fully described in the Tutorial 5: Building an application that comes with the NoesisGUI SDK.
Thanks.
Re: Unable to use XAML player
The documentation is located at index.html, in the root directory after unzipping the .7z package.Where are the Tutorials located?
-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: Unable to use XAML player
The window is black because the Background property of the Window is not set, and the default value is null. If you want your window to have a color or gradient background you should set the Background property accordingly.Thanks for the fast reply,
I have managed to get it working now, however it appears that the window was still appearing black as I was referencing styles (Style="{DynamicResource LoginButton}") in the window.
The problem that makes your controls not visible is because in NoesisGUI there is no default style to rely on for the properties that are not set in your Style. So when you set the Style property of a Control, the Style object must have a Setter for the Template property with a valid ControlTemplate defined or be BasedOn a Style with the Template property correctly set. Otherwise the Control would not have a visual tree to be rendered.

Who is online
Users browsing this forum: Google [Bot] and 2 guests