Re: A data binding question
Posted: 14 Feb 2018, 17:22
If you asked me, I made maybe mistake and my examples working only for me, because I use it for language and My DataContext is set in codebehind. I'll give you how I done language and you try get idea for your needs, I think it is similar scenario where other elements have same data context, but in different views, windows etc..
in C++
Inside MainGrid I have another grid where is whole GUI, and this MainGrid is use for display other views.
And all bindings from Language have this code:
in C++
Code: Select all
// !-- important things
// /* LANGUAGE.h*/ //
NS_DECLARE_SYMBOL(Language); // !--
class LanguageModel : public Noesis::BaseComponent, public Noesis::INotifyPropertyChanged
{
public:
/// ...
NS_IMPLEMENT_INTERFACE_FIXUP;
private:
// ...
Noesis::ResourceDictionary * m_RD;
///
Noesis::PropertyChangedEventHandler changed;
void Changed(NsSymbol prop);
NS_IMPLEMENT_INLINE_REFLECTION(LanguageModel, Noesis::BaseComponent)
{
NsMeta<Noesis::TypeId>("languageModel");
NsImpl<Noesis::INotifyPropertyChanged>();
NsProp("Language" , &LanguageModel::m_RD); // !--
}
};Code: Select all
// /* MAINGRID.cpp*/ //
MainGrid::MainGrid()
{
this->SetDataContext(MyDelegate::m_LangModel); // m_LangModel is LanguageModel class
// ...
}Code: Select all
<!-- XAML MainGrid -->
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
x:Name="MainGrid"
x:Class="MainGrid"
>And all bindings from Language have this code:
Code: Select all
// "{Binding ElementName=MainGrid, Path=DataContext.Language[nameBunding]}"
<GroupBox Header="{Binding ElementName=MainGrid, Path=DataContext.Language[h_options]}" >