Witam wszystkich!

Mam taki kod:

                var rbA = new RadioButton();
                rbA.Name = "a";
                Thickness margin = rbA.Margin;
                margin.Left = 15;
                rbA.Margin = margin;
                rbA.Foreground = Brushes.White;

                stackPanel.Children.Add(rbA);

Niestety kontrolka się nie dodaje, a zamiast tego wyrzuca błąd o treści:

An unhandled exception of type 'System.NullReferenceException' occurred in Guitar Pro Learning Tool.exe

Nie mam pojęcia w czym rzecz, proszę o pomoc.