Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add events to templated control in silverlight?
    text
    copied!<p>Bounty Rewarded for any solid tutorial/learning resources regarding wiring up events with templated controls.</p> <p>I Have a control template like this: </p> <pre><code>&lt;Style TargetType="local:DatePicker"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="local:DatePicker"&gt; &lt;Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" x:Name="myDatePickerContentArea"&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;Button x:Name="myTestButton" Content="Test button" /&gt; &lt;telerik:RadDatePicker Style="{StaticResource VisitsReportTextBoxStyle}" Foreground="#FFFFFF" x:Name="startDate" DateTimeWatermarkContent="Start Date"/&gt; &lt;telerik:RadDatePicker Style="{StaticResource VisitsReportTextBoxStyle}" x:Name="endDate" DateTimeWatermarkContent="End Date"/&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>The C# for this template is: </p> <pre><code>public class DatePicker : Control { public static readonly DependencyProperty StartDateSelectedDateProperty = DependencyProperty.Register("StartDateSelectedDateProperty", typeof(DateTime), typeof(DatePicker), null); public DateTime? StartDateSelectedDate { get; set; } public DatePicker() { this.DefaultStyleKey = typeof(DatePicker); } public override void OnApplyTemplate() { RadDatePicker StartDate = this.GetTemplateChild("startDate") as RadDatePicker; StartDate.SelectionChanged += new Telerik.Windows.Controls.SelectionChangedEventHandler(StartDate_SelectionChanged); StartDate.SelectedDate = new DateTime(2010, 01, 01); base.OnApplyTemplate(); } void StartDate_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e) { RadDatePicker temp = (RadDatePicker)sender; StartDateSelectedDate = temp.SelectedDate; } } </code></pre> <p>My selectionChanged Event Doesn't Fire and I'm not sure why. Any Ideas ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload