- darthmaule2
- Posts: 98
- Joined:
Adding to C# API demo app -- BuildTool not finding my clases
As a first attempt to try using C# code behind, I started with the solution from NoesisGUI-Mono-1.2.2b.zip.
I added a new C# Class Library project with classes for a data item and a data model.
Unfortunately, when I try to build the xaml file that uses my classes, BuildTool cannot locate the data model, even though my dll is in the directory.
I copied the files from the 1.2.2 SDK Bin directory into the directory with the xaml file and my C# dll with the classes shown above.
Running the BuildTool gives the error:
Ignoring unknown type 'NoesisGuiExtensions.StatusBarAreaModel' (@9.6)
I must be missing an export or register that is needed.
When using C++ Code behind, the dll implements NsRegisterReflection(), but I did not think that was needed for C++.
I added a new C# Class Library project with classes for a data item and a data model.
Unfortunately, when I try to build the xaml file that uses my classes, BuildTool cannot locate the data model, even though my dll is in the directory.
Code: Select all
namespace NoesisGuiExtensions
{
public class StatusBar_Item : BaseComponent, INotifyPropertyChanged
{
public StatusBar_Item(string statusItemText, TextureSource textureSource)
{
_statusItemText = statusItemText;
_textureSource = textureSource;
}
private string _statusItemText = "";
public string StatusItemText
{
get { return _statusItemText; }
set
{
if (_statusItemText != value)
{
_statusItemText = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("StatusItemText"));
}
}
}
private TextureSource _textureSource = null;
public TextureSource StatusItemTextureSource
{
get { return _textureSource; }
set
{
if (_textureSource != value)
{
_textureSource = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("StatusItemTextureSource"));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
Code: Select all
namespace NoesisGuiExtensions
{
public class StatusBarAreaModel : ItemsControl
{
public ObservableCollection<StatusBar_Item> StatusBarItemList { get; private set; }
public StatusBarAreaModel()
{
StatusBarItemList = new ObservableCollection<StatusBar_Item>();
}
public bool AddItem( string statusItemText, TextureSource textureSource)
{
StatusBar_Item item = new StatusBar_Item(statusItemText, textureSource);
StatusBarItemList.Add(item);
return true;
}
}
}
Code: Select all
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NoesisGuiExtensions" >
<UserControl.Resources>
<local:StatusBarAreaModel x:Name="statusDataModel"/>
</UserControl.Resources>
Running the BuildTool gives the error:
Ignoring unknown type 'NoesisGuiExtensions.StatusBarAreaModel' (@9.6)
I must be missing an export or register that is needed.
When using C++ Code behind, the dll implements NsRegisterReflection(), but I did not think that was needed for C++.
Re: Adding to C# API demo app -- BuildTool not finding my cl
Right now, the C# SDK does not include a BuildTool so code-behind is not working yet. We are working on it. Meanwhile the workaround is avoiding the x:class keyword and use code instead. For example, for data contexts you must set the DataContext property by code. Or for your example, something like:
This is just a temporary workaround. Sorry for the inconvenience.
Code: Select all
StatusBarAreaModel statusBarAreaMode = new StatusBarAreaModel();
ucRoot.Resources["statusDataModel"] = statusBarAreaMode;
Who is online
Users browsing this forum: No registered users and 74 guests