- leonid_golovko
- Posts: 13
- Joined:
Click on button from main user control to triger event at other class.
Hi.
I have a screen with a button and a circle.
The circle has its own view model, user control and xaml.
The button is located in other user control file.
I need to be able to press the button and be able to change the visibility of my circle.
All the buttons on the circle are binded but nothing changes when I press the button.
It goes to the on press function and does the set of the visibility and nothing changes.
The visibility does changes when i change the initial visibility value to true or false in the xaml or when I initiate the bool value to true or false.
Here is the code in the user control of the circle.
Here is the code of the xaml part of the circle:
How to make it communicate?
It worked before a separated the circle into another class.
I have a screen with a button and a circle.
The circle has its own view model, user control and xaml.
The button is located in other user control file.
I need to be able to press the button and be able to change the visibility of my circle.
All the buttons on the circle are binded but nothing changes when I press the button.
It goes to the on press function and does the set of the visibility and nothing changes.
The visibility does changes when i change the initial visibility value to true or false in the xaml or when I initiate the bool value to true or false.
Here is the code in the user control of the circle.
Code: Select all
NS_IMPLEMENT_REFLECTION(DataModelApp::CircleUserControl, "DataModelApp.CircleUserControl") {
Noesis::UIElementData* data = NsMeta<Noesis::UIElementData>(Noesis::TypeOf<SelfClass>());
auto onValueChanged = [](DependencyObject* d, const Noesis::DependencyPropertyChangedEventArgs& e) {
CircleUserControl* control = Noesis::DynamicCast<CircleUserControl*>(d);
std::cout << "CallBack" << std::endl;
if (control != nullptr)
{
control->m_viewModel->SetCircleVisibility(!control->m_viewModel->GetCircleVisibility());
}
};
data->RegisterProperty<bool>(is_circle_visible_property, "CircleVisibility", Noesis::PropertyMetadata::Create(bool(true), Noesis::PropertyChangedCallback(onValueChanged)));
}
Code: Select all
<local:CircleUserControl CircleVisibility = "{Binding CircleVisibilityMain, Converter={StaticResource BooleanToVisibilityConverter}}"/>
It worked before a separated the circle into another class.
- leonid_golovko
- Posts: 13
- Joined:
Re: Click on button from main user control to triger event at other class.
If its possible please write a simple example.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 3 guests