darthmaule2
Topic Author
Posts: 98
Joined: 23 Oct 2014, 19:54

Adding to C# API demo app -- BuildTool not finding my clases

21 Apr 2015, 16:38

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.
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;
    }
}
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;
        }
    }
}
<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>
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++.
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Adding to C# API demo app -- BuildTool not finding my cl

22 Apr 2015, 13:29

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:
StatusBarAreaModel statusBarAreaMode = new StatusBarAreaModel();
ucRoot.Resources["statusDataModel"] = statusBarAreaMode;
This is just a temporary workaround. Sorry for the inconvenience.

Who is online

Users browsing this forum: No registered users and 74 guests