- realesmedia
- Posts: 85
- Joined:
How to determine what UIElement::Layout changed?
analog WPF event
Code: Select all
UIElement.LayoutUpdated()
-
sfernandez
Site Admin
- Posts: 2995
- Joined:
Re: How to determine what UIElement::Layout changed?
WPF's LayoutUpdated event occurs when the layout of the various visual elements associated with the current Dispatcher changes. That means that elements that have been measured and arranged can be different from the one raising the event. At the end the event will only specify if any element was measured/arranged, nothing else.
Is that something you are interested in?
Is that something you are interested in?
- realesmedia
- Posts: 85
- Joined:
Re: How to determine what UIElement::Layout changed?
I needed to subscribe to the event of changing the position (dragging) + zoom of the element relative to parent
I only needed an event
I have already found another solution)))
thanks
I only needed an event
I have already found another solution)))
thanks
Re: How to determine what UIElement::Layout changed?
I hate it when someone just says "I found a solution" but doesn't post it. Others may have the same issue as you!
Please share what you did. I'm looking for a layout event also. I want to align some data with the screen position and size of the element after it changes. I have no idea how to do this! :(
Please share what you did. I'm looking for a layout event also. I want to align some data with the screen position and size of the element after it changes. I have no idea how to do this! :(
Re: How to determine what UIElement::Layout changed?
The other thing I find a little odd, besides the missing event, is that a user control doesn't have anything to override related to this either. My other thought was creating a user control that could respond to the layout changes and inform my game. But there aren't very many methods to override.
Re: How to determine what UIElement::Layout changed?
I had to subscribe to notifications of Movement and resizing of parent elements. The solution depends on the xaml hierarchy.I hate it when someone just says "I found a solution" but doesn't post it. Others may have the same issue as you!
Please share what you did. I'm looking for a layout event also. I want to align some data with the screen position and size of the element after it changes. I have no idea how to do this! :(
Code: Select all
ConnectorControl::ConnectorControl()
{
InitializeComponent();
Loaded() += [this] (BaseComponent*, const RoutedEventArgs& e) {
if (m_node = Helper::GetParentRecursive<NodeControl>(this)) {
if (auto behaviors = NoesisApp::Interaction::GetBehaviors(m_node)) {
if (auto behavior = Noesis::DynamicCast<TransformBehavior*>(behaviors->Get(0))) {
behavior->TranslateChanged() += Noesis::MakeDelegate(this, &ConnectorControl::OnLayoutUpdated);
}
}
}
if(m_control = Helper::GetParentRecursive<ItemsControl>(this)) {
if (auto parent = m_control->GetParent()) {
parent->SizeChanged() += MakeDelegate(this, &ConnectorControl::OnLayoutUpdated);
}
}
if (auto graph = Helper::GetParentRecursive<NodeGraphControl>(this)) {
m_canvas = graph->FindName<Canvas>("PART_Canvas");
OnLayoutUpdated();
}
};
}
Re: How to determine what UIElement::Layout changed?
Thanks. I'll look into using that! It would be nice if this was supported by the API :) I see there is a bug that's been opened for years related to adding it.
-
sfernandez
Site Admin
- Posts: 2995
- Joined:
Re: How to determine what UIElement::Layout changed?
All elements have a SizeChanged event that indicates its render size changed, is that what you are looking for?
Re: How to determine what UIElement::Layout changed?
I have a ConnectionControl that connects nodes via Pin.
The connection should monitor any events that lead to changes in Pin positions.
in my opinion, the notification UIElement.LayoutUpdated() is best suited for this.
The connection should monitor any events that lead to changes in Pin positions.
in my opinion, the notification UIElement.LayoutUpdated() is best suited for this.
-
sfernandez
Site Admin
- Posts: 2995
- Joined:
Re: How to determine what UIElement::Layout changed?
I agree, for that scenario having the LayoutUpdated event would help, although as I mentioned earlier, that event is a bit confusing because it is raised when ANY element in the tree gets updated, not only when the element where you register the event handler changes its layout.
We will implement the LayoutUpdated event for the next release: #1041
We will implement the LayoutUpdated event for the next release: #1041
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 18 guests