-
- a.lashkevich
- Posts: 11
- Joined:
c++ vector binding
hi noesis team, please help
how to bind vector of strings? I tried several ways and got errors in each of them
how to bind vector of strings? I tried several ways and got errors in each of them
Re: c++ vector binding
There are bits unfinished about this in our type system. For example, we have the TypeArray and TypeCollection classes and a specialization of TypeOf<> for static arrays.
So static arrays of Noesis::String should work. This could be extended also to support Noesis::Vector and std::vector. If this is important to you, please create a ticket for it.
The alternative right now, less efficient, is having an ObservableCollection of Strings.
Code: Select all
////////////////////////////////////////////////////////////////////////////////////////////////////
/// TypeOfHelper for static arrays
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class T, uint32_t N> struct TypeOfHelper<T[N]>: public TypeOfHelperBase<T[N], TypeArray>
{
static Symbol GetName()
{
char str[256];
snprintf(str, 256, "%s[%d]", TypeOf<T>()->GetName(), N);
return Symbol(str);
}
static void Fill(Type* type)
{
TypeArray* typeArray = (TypeArray*)(type);
typeArray->SetElemCount(N);
typeArray->SetElemSize(sizeof(T));
typeArray->SetElemType(TypeOf<T>());
}
};
The alternative right now, less efficient, is having an ObservableCollection of Strings.
-
- a.lashkevich
- Posts: 11
- Joined:
Re: c++ vector binding
thanks for answer,
ObservableCollection of Strings is not working because ObservableCollection works only with BaseComponent* and String is not inherited from BaseComponent,
also Noesis::String items[5]; compiles but I get crash when I try to open screen.
I just want to bind collection of string to combobox ( <ComboBox ItemsSource="{Binding Items}"/> ).
How is best way to do that now? Could you please post working code with TypeOfHelper<Vector<T>> ?
I can wrap my string in view model and use ObservableCollection of view models and get string as field, but it looks not good
ObservableCollection of Strings is not working because ObservableCollection works only with BaseComponent* and String is not inherited from BaseComponent,
also Noesis::String items[5]; compiles but I get crash when I try to open screen.
I just want to bind collection of string to combobox ( <ComboBox ItemsSource="{Binding Items}"/> ).
How is best way to do that now? Could you please post working code with TypeOfHelper<Vector<T>> ?
I can wrap my string in view model and use ObservableCollection of view models and get string as field, but it looks not good
Re: c++ vector binding
You can box the strings in the collection. That should work.ObservableCollection of Strings is not working because ObservableCollection works only with BaseComponent* and String is not inherited from BaseComponent,
Who is online
Users browsing this forum: No registered users and 3 guests