4
我有一個與this one有關的問題:我嘗試將一個事件附加到我的StackPanel,但在使用XamlReader時它不會連接。我無法獲取調用ChildItem_Load方法。有誰知道一種方法來做到這一點?將事件處理程序附加到代碼生成的DataTemplate
除了這個事件代碼工作正常。
this._listBox.ItemTemplate = (DataTemplate) XamlReader.Load(
@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
<Border>
<StackPanel Loaded=""ChildItem_Loaded"">
<TextBlock Text=""{Binding " + this._displayMemberPath + @"}"" />
</StackPanel>
</Border>
</DataTemplate>"
尼斯的答案 - 謝謝! – edtheprogrammerguy 2013-05-23 20:39:10