Indexer property for data binding with C++ API
Hi,
Just want to make sure. Is the indexer property is supported with C++ API ?
From https://www.noesisengine.com/docs/Gui.C ... orial.html, it seems that it is only supported in C#.
Just want to make sure. Is the indexer property is supported with C++ API ?
From https://www.noesisengine.com/docs/Gui.C ... orial.html, it seems that it is only supported in C#.
Re: Indexer property for data binding with C++ API
Arrggh, I post to a wrong forum !
Sorry, please delete this entry.
Sorry, please delete this entry.
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Indexer property for data binding with C++ API
In C++ your view model hast to implement the IListIndexer or IDictionaryIndexer interface.
Then you can use the [] in the binding path on your data (in the following sample SomeIndexer property will return an instance of IndexerTest):
Code: Select all
class IndexerTest: public BaseComponent, public IListIndexer
{
public:
int _array[3];
// IListIndexer
bool TryGet(uint32_t index, Ptr<BaseComponent>& item) const override
{
if (index < 3)
{
item = Boxing::Box<int>(_array[index]);
return true;
}
return false;
}
virtual bool TrySet(uint32_t index, BaseComponent* item) override
{
if (index < 3 && Boxing::CanUnbox<int>(item))
{
_array[index] = Boxing::Unbox<int>(item);
return true;
}
return false;
}
NS_IMPLEMENT_INLINE_REFLECTION(IndexerTest, BaseComponent)
{
NsImpl<IListIndexer>();
}
};
Code: Select all
<TextBlock Text="{Binding A.B.SomeIndexer[2]}"/>
Re: Indexer property for data binding with C++ API
I see.
I have further a question. Is it possible to use enum as an index for binding ?
Something like
Thanks.
I have further a question. Is it possible to use enum as an index for binding ?
Something like
Code: Select all
<TextBlock Text="{Binding A.B.SomeIndexer[MyEnum.Test]}"/>
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Indexer property for data binding with C++ API
Unfortunately no, current implementation only expects an integer (IListIndexer) or a string (IDictionaryIndexer). So the 'MyEnum.Test' would be interpreted as a string key into the dictionary indexer.
If you need that feature, could you please report it in our bugtracker?
If you need that feature, could you please report it in our bugtracker?
Re: Indexer property for data binding with C++ API
Hi, thanks for the confirmation. I filed the issue here:
https://www.noesisengine.com/bugs/view.php?id=1396
https://www.noesisengine.com/bugs/view.php?id=1396
Re: Indexer property for data binding with C++ API
Thanks Niko!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 55 guests