0

当我尝试单击 StackPanel 中的动态控件时遇到了一些麻烦。我以这种方式向 Grid 添加控件...

void Opt()
    {
        TextBlock Title_1 = new TextBlock();
        TextBlock Title_2 = new TextBlock();
        CheckBox Kwota_exists = new CheckBox();
        TextBox Title = new TextBox();
        StackPanel Frame = new StackPanel();
        Button OK = new Button();

        Title_1.Text = "Dodaj kategorię";
        Title_2.Text = "Aktywne kategorię";
        Kwota_exists.Content = "Stała kwota?";
        Title.Text = "Nazwa kategorii";
        OK.Content = "Dodaj";
        OK.IsEnabled = true;
        OK.IsHitTestVisible = true;
        OK.IsTabStop = true;
        OK.ClickMode = ClickMode.Release;
        Frame.IsHitTestVisible = true;

        Kwota_exists.Checked +=Kwota_exists_Checked;

        Title_1.FontSize = 50;
        Title_2.FontSize = 50;
        Title.FontSize = 20;
        Frame.Height = 100;
        Frame.Width = 400;

        Title_1.Margin = new Thickness(0, 0, 0, 0);
        Title_2.Margin = new Thickness(0, 220, 0, 0);
        Frame.Margin = new Thickness(0, 70, 0, 0);

        Frame.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
        Frame.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
        Frame.Orientation = Orientation.Horizontal;

        Frame.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(145, 56, 234, 21));

        Frame.Children.Add(Kwota_exists);
        Frame.Children.Add(Title);
        Frame.Children.Add(OK);


        GrdContent.Children.Add(Frame);
        GrdContent.Children.Add(Title_1);
        GrdContent.Children.Add(Title_2);

    }

但是当我尝试单击按钮或选中复选框控件时似乎没有响应(不可点击)。看起来我无法访问它们或者我做错了什么。如果有人向我解释我在哪里做错了,我会很认真。

4

0 回答 0