❔ How do I pass in the parent ContentView to a class contained in the XAML? Is it possible?
For example:
And have the constuctor of MyClass get the type MyView.
Also tried variations of <x:Arguments> to include the x:Class="", ...
5 Replies
With ContentView as the argument type it does get me a little closer but the object passed in to my constructor is not of the type I was expecting.
this seems like a horrific design pattern
but, uhhh
so, you want
MyClass
to be given the instance of ContentView
that it belongs to?
this, I think, should do it
if not, I dunno
but I can almost guarantee you there's a better way to do whatever it is you're trying to doAgreed, for XAML. But done all the time in C++. This is a new framework to me and there are a few things that would be done better. My "control" is derived from GraphicsView, and the control is used by XAML ContentView. "Parent" is the enclosing view, which was null at time the constructor is called. That design probably should be looked at more than once. If Parent is null then there is no parent. I ended up using the Loaded event of the view.
Thank you for taking the time to propose a solution.
it's not really a XAML/C++ thing
it's the fact that it looks like you're mixing layers, and thus mixing responsibilities
if you feel like explaining your scenario more, I can probably provide more context on what a "good" pattern would be
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.