Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Implement "SizeChanged" #9311

Closed
timunie opened this issue Oct 31, 2022 Discussed in #8473 · 2 comments · Fixed by #9307
Closed

How to Implement "SizeChanged" #9311

timunie opened this issue Oct 31, 2022 Discussed in #8473 · 2 comments · Fixed by #9307

Comments

@timunie
Copy link
Contributor

timunie commented Oct 31, 2022

Discussed in #8473

Originally posted by yaoyulian July 9, 2022
In WPF: <>UserControl SizeChanged="UserControl_SizeChanged"
Avalonia do not have "SizeChanged". I tryed "LayoutUpdated", But it made UI halted. Please Add "SizeChanged".

@robloo

@sakya
Copy link

sakya commented Nov 1, 2022

You can observe the bounds property

  _canvas = this.FindControl<Canvas>("Canvas");
  var bounds = _canvas.GetObservable(Canvas.BoundsProperty);
  bounds.Subscribe(value =>
  {
      ...
  });

@robloo
Copy link
Contributor

robloo commented Nov 1, 2022

@sakya Yes, I know. SizeChanged has some advantages:

  1. For better compatibility with WPF
  2. Doesn't require ReactiveUI methodology
  3. It actually has more features
  4. It only checks for size (not position) changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants