public class BlockGrid : Grid
{
bool IsFirstTimeLoad = true;
public BlockGrid()
{
if (!DesignerProperties.GetIsInDesignMode( this ))
{
this.Loaded += BlockGrid_Loaded;
}
}
private void BlockGrid_Loaded( object sender, RoutedEventArgs e )
{
if(IsFirstTimeLoad)
{
this.IsFirstTimeLoad = false;
DefinitionLoad();
Panel.SetZIndex( this, this.ZIndex );
}
}
private void DefinitionLoad()
{
if (!DesignerProperties.GetIsInDesignMode( this )/* && ColumnCount > 0 && RowCount > 0*/)
{
for (int c = 0; c < ColumnCount; c++)
{
this.ColumnDefinitions.Add( new ColumnDefinition() );
}
for(int r = 0; r < RowCount; r++)
{
this.RowDefinitions.Add(new RowDefinition() );
}
for(int col = 0; col < ColumnCount; col++)
{
for(int row = 0; row < RowCount; row++)
{
var block = new Block
{
Margin = new Thickness( 2 ),
Title = String.Format("{0}x{1}", col, row),
};
Grid.SetColumn(block, col);
Grid.SetRow( block, row );
this.Children.Add( block );
}
}
}
}
이와 같은 Custom Control Class가 있습니다.
동적으로 Column 과 Row를 추가해주고 있는데요,
Build를 하지 않은 상태에서 wpf designer에서 동적으로 추가된 항목들이 update 되어 보이질 않네요,
어떤 부분 때문일까요 ?
++추가
Build 해서 실행시키면 정상적으로 Display 됩니다.