Thanks I had a couple of problems with the logic of DependencyProperties. I found a short but good tutorial in web. After that I made a couple of changes and now it works:
public static readonly DependencyProperty Symbol1Name =
DependencyProperty.Register("Sym1Name", typeof(string), typeof(UserControl1), new FrameworkPropertyMetadata(new string('t',10), OnSymbol1PropertyChanged));
public string Sym1Name
{
get { return (string) this.GetValue(Symbol1Name); }
set { this.SetValue(Symbol1Name, value); }
}
private static void OnSymbol1PropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
UserControl1 ak = dependencyObject as UserControl1;
ak.InitName(e,0);
}
This following functions creates a new Column with a couple of elements.
public void InitName(DependencyPropertyChangedEventArgs e, int column)
{
string test = e.NewValue.ToString();
ColumnDefinition c1 = new ColumnDefinition();
newColumnDefinition(c1, test);
newBoarder(column);
newGraphic(column, test);
CreateDynamicExpander(column);
if (!istGerade(column)) Grid1.ColumnDefinitions[column].Width = new GridLength(0);
Grid1.HorizontalAlignment = HorizontalAlignment.Stretch;
Grid1.VerticalAlignment = VerticalAlignment.Top;
}