realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

How to determine what UIElement::Layout changed?

13 Jun 2019, 20:25

analog WPF event
 UIElement.LayoutUpdated()
 
User avatar
sfernandez
Site Admin
Posts: 2995
Joined: 22 Dec 2011, 19:20

Re: How to determine what UIElement::Layout changed?

17 Jun 2019, 17:01

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?
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

Re: How to determine what UIElement::Layout changed?

18 Jun 2019, 10:19

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
 
Thraka
Posts: 6
Joined: 12 Mar 2018, 19:38

Re: How to determine what UIElement::Layout changed?

06 Jul 2022, 18:56

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! :(
 
Thraka
Posts: 6
Joined: 12 Mar 2018, 19:38

Re: How to determine what UIElement::Layout changed?

07 Jul 2022, 17:30

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.
 
Logrus
Posts: 54
Joined: 22 Jul 2015, 12:16

Re: How to determine what UIElement::Layout changed?

09 Jul 2022, 13:54

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! :(
I had to subscribe to notifications of Movement and resizing of parent elements. The solution depends on the xaml hierarchy.
	
	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();
			}
		};
	}
 
Thraka
Posts: 6
Joined: 12 Mar 2018, 19:38

Re: How to determine what UIElement::Layout changed?

09 Jul 2022, 20:17

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.
 
User avatar
sfernandez
Site Admin
Posts: 2995
Joined: 22 Dec 2011, 19:20

Re: How to determine what UIElement::Layout changed?

11 Jul 2022, 18:51

All elements have a SizeChanged event that indicates its render size changed, is that what you are looking for?
 
Logrus
Posts: 54
Joined: 22 Jul 2015, 12:16

Re: How to determine what UIElement::Layout changed?

13 Jul 2022, 15:21

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.
 
User avatar
sfernandez
Site Admin
Posts: 2995
Joined: 22 Dec 2011, 19:20

Re: How to determine what UIElement::Layout changed?

15 Jul 2022, 12:07

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

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 18 guests