leonid_golovko
Topic Author
Posts: 13
Joined: 13 Jun 2024, 15:06

Click on button from main user control to triger event at other class.

10 Jul 2024, 12:45

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.
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)));
    }
Here is the code of the xaml part of the circle:
<local:CircleUserControl CircleVisibility = "{Binding CircleVisibilityMain, Converter={StaticResource BooleanToVisibilityConverter}}"/>
How to make it communicate?
It worked before a separated the circle into another class.
 
leonid_golovko
Topic Author
Posts: 13
Joined: 13 Jun 2024, 15:06

Re: Click on button from main user control to triger event at other class.

10 Jul 2024, 12:53

If its possible please write a simple example.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 3 guests