Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Datatemplate event via XamlReader
3 replies. Latest Post by Jonathan Shen – MSFT on November 28, 2008.
(0)
jkattest...
Member
24 points
29 Posts
11-23-2008 10:35 AM |
Hello,
I'm trying to create a datatemplate column with an event, but it doesn't fire.
checkTemplate.Append(
checkEditTemplate.Append(
((
{
}
If i define the template through a resource the event does fire.
bryant
Star
9447 points
1,558 Posts
11-23-2008 5:43 PM |
The XamlReader doesn't support adding events. Instead, give your checkbox an x:Name and then once you add your Xaml to the tree you can find it and attach the event handler.
11-24-2008 3:40 PM |
Bryant,
Thanks for your response. This seems to work but ...
column =
:
column.Header = field.ShortLabel;
dataGrid.Columns.Add(column);
The findname returns null, how do i find my control?
Jonathan...
All-Star
23562 points
2,304 Posts
11-28-2008 12:31 AM |
Hi Jkat,
Unfortunately we can't. Controls in a DataTemplate reside in a separate name scope. The only way to modify the control is to create an event handler for the control, and use the sender parameter to get a reference of the control.Best regards,Jonathan
Normal 0 7.8 pt 0 2 false false false EN-US ZH-CN X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;}