我已动态创建了带有多个边框的WrapPanel(_wp)。我需要为每个边框创建处理程序。我怎么能通过C#来做到这一点?
for (int k = 1; k < i+1; k++)
{
_b = new Border()
{
Margin = new Thickness(0, 5, 5, 0),
BorderBrush = new SolidColorBrush(Colors.Blue),
BorderThickness = new Thickness(3, 3, 3, 3),
Background = new SolidColorBrush(Colors.Transparent),
Child = new TextBlock()
{
Text = k.ToString(),
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
VerticalAlignment = System.Windows.VerticalAlignment.Center,
FontSize = 28,
}
};
_wp.Children.Add(_b);
}
我需要Tap处理程序。
答案 0 :(得分:1)
只需使用
_b.Tap += yourHandler;