Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

User Control's child event in Window?

$
0
0

Hi I don't know if this is an appropriate question to ask, but am new to WPF so a lot of things are still confusing.

I have an user control, say CustomSliderCtrl. Within that user control I have a slider control and few other controls. Now I have a window where multiple instances of CustomSliderCtrl are present. Each CustomSliderCtrl  serve a specific purpose and they are differentiated by an enum variable i have within the user control. The enum says what type of slider control it is. 

Now on value change of any CustomSliderCtrl within the window, i need to be notified of the value and this is how I implemented it. I exposed a delegate and an event from CustomSliderCtrl and invoke the event on value change event handler of the slider control. This means for all the CustomSliderCtrl i have within my window i need to register that event to event handlers and handle it.

Is there a way like i use an event handler like this? 

<window Name="Window1" local:CustomSliderCtrl.Slider.ValueChanged="OnValueChangedEvent">

<CustomSliderCtrl Name="Ctrl1"/>

<CustomSliderCtrl Name="Ctrl2"/>

<CustomSliderCtrl Name="Ctrl3"/>

</Window>

instead of 

<window Name="Window1" >

<CustomSliderCtrl Name="Ctrl1" OnValueChanged="Ctrl1_OnValueChanged"/>

<CustomSliderCtrl Name="Ctrl2" OnValueChanged="Ctrl2_OnValueChanged"/>

<CustomSliderCtrl Name="Ctrl3" OnValueChanged="Ctrl3_OnValueChanged"/>

</Window>

I know it sounds odd, but please clarify.


-------------kings--------------


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>