View Issue Details

IDProjectCategoryView StatusLast Update
0001536NoesisGUIC++ SDKpublic2019-08-22 01:29
ReporterstevehAssigned Tojsantos 
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Product Version2.2.1 
Target VersionFixed in Version 
Summary0001536: Can't bind to array index element - "Array properties can't be boxed"
DescriptionHi guys, trying to bind to a fixed array declared in a data model. This works fine in Blend but I hit an assert in the C++ API here:

template<class T, uint32_t N>
Ptr<BaseComponent> TypePropertyArray<T,N>::GetComponent(const void*) const
{
    // Array properties can't be boxed
    NS_ASSERT_UNREACHABLE;
}

This is my data model

// C#
class Baz
{
    public Baz() : i(0) {}
    public int i { get; set;}
}
class Foo
{
    public Foo() { Bar = new Baz[2]; }
    public Baz Bar[];
};

// WPF
<TextBlock Text="{Binding Bar[0].i}" >
    <TextBlock.DataContext>local:Foo</TextBlock.DataContext>
</TextBlock>

// C++ .h
class Baz : BaseComponent
{
public:
    int i = 0;
    NS_DECLARE_REFLECTION(Baz, BaseComponent)
}
class Foo : BaseComponent
{
 public:
    Foo();
    Ptr<Baz> Bar[2];
private:
    NS_DECLARE_REFLECTION(Foo, BaseComponent)
}

// C++ .cpp
Foo::Foo() {
    Bar[0] = MakePtr<Baz>();
    Bar[1] = MakePtr<Baz>();
}

NS_IMPLEMENT_REFLECTION(Baz)
{
    NsMeta<Noesis::TypeId>("Local.Baz");
    NsProp("i", &SelfClass::i);
}

NS_IMPLEMENT_REFLECTION(Foo)
{
    NsMeta<Noesis::TypeId>("Local.Foo");
    NsProp("Bar", &SelfClass::Bar);
}
Steps To Reproduce1. Have a fixed array of objects derived from BaseComponent in a data model.
2. Try to bind to an index on a component.
3. Try to instance the component, see the assert fire.
TagsNo tags attached.
PlatformAny

Activities

jsantos

jsantos

2019-08-22 01:29

manager   ~0005935

Right now this is not possible, you need to use an ObservableCollection. Yeah, I know it is far from optimal and not as efficient as a static array.
This scenario and more things are going to be improved in the next reflection architecture we are working on.

Issue History

Date Modified Username Field Change
2019-08-13 18:45 steveh New Issue
2019-08-22 01:28 jsantos Assigned To => jsantos
2019-08-22 01:28 jsantos Status new => assigned
2019-08-22 01:29 jsantos Note Added: 0005935