0

我已经动态创建了带有多个边框的 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); 
        }

我需要水龙头处理程序。

4

1 回答 1

1

只需使用

 _b.Tap += yourHandler;
于 2012-04-05T14:39:33.443 回答