Event handlers on nested custom controls in WPF

  • Thread starter Thread starter sundarvenkata
  • Start date Start date
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
 
"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
 
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
 
Back
Top