1
click 이벤트를 datatemplate의 단추에 추가하려고합니다. 내가 버튼으로 클릭하면DataTemplate의 XamlReader 동적 이벤트
var temp = (DataTemplate)XamlReader.Load(
new MemoryStream(Encoding.Default.GetBytes(
@"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'><Button><TextBlock Text='1' TextAlignment='Center'/></Button></DataTemplate>"
)));
var button = temp.LoadContent() as Button;
button.Click += (sender, args) =>
{
MessageBox.Show("123");
};
return temp;
그래서, 아무 일도 발생하지 : 몇 가지 코드를 가지고 . 내가 무엇을 놓치고 있습니까?