Event handlers on nested custom controls in WPF

S

sundarvenkata

Hi All,

I have a custom control in my WPF project which is roughly defined
like this:

<UserControl>

<StackPanel SizeChanged="OuterPanel_SizeChanged">

</StackPanel>

<StackPanel x:Name="childrenHolderPanel">

</StackPanel>
<UserControl>

At some point of time in the course of the application execution, I
add this custom control (dynamically) into the
"childrenHolderPanel" (i.e., custom control inside the custom control
kinda like a tree). After that, the event "OuterPanel_SizeChanged" in
the parent control no longer works (however the same event works for
the child custom control). Is this a bug or am I missing something?

Thanks,
Sundar
 
M

miher

"sundarvenkata" <[email protected]> az alábbiakat írta a következo
üzenetben
Hi All,

I have a custom control in my WPF project which is roughly defined
like this:

<UserControl>

<StackPanel SizeChanged="OuterPanel_SizeChanged">

</StackPanel>

<StackPanel x:Name="childrenHolderPanel">

</StackPanel>
<UserControl>

At some point of time in the course of the application execution, I
add this custom control (dynamically) into the
"childrenHolderPanel" (i.e., custom control inside the custom control
kinda like a tree). After that, the event "OuterPanel_SizeChanged" in
the parent control no longer works (however the same event works for
the child custom control). Is this a bug or am I missing something?

Thanks,
Sundar

Hi,
Can You please clarify the posted xaml since the usercontrol is having 2
root elements at the moment what is not possible afaik.
-Zsolt
 
S

sundarvenkata

Hi Zsolt,

Thanks for the response. I am sorry I did not post the usercontrol
definition accurately. This is the actual definition.

<UserControl>

<StackPanel>

<StackPanel SizeChanged="OuterPanel_SizeChanged">

</StackPanel>

<StackPanel x:Name="childrenHolderPanel">

</StackPanel>

</StackPanel>

<UserControl>

Thanks,
Sundar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top