Monday, October 3, 2011

WPF- How to find the height/width of a WPF control added dynamically

//Dynamically cretaed TextBlock
TextBlock objTextBlock = new TextBlock();
objTextBlock.Loaded += new RoutedEventHandler(objTextBlock_Loaded);

//Access the dimensions using ActualHeight and ActualWidth in this event.

void
objTextBlock_Loaded(object sender, RoutedEventArgs e)
{
TextBlock objTextBlock = sender as TextBlock;


MessageBox.Show(objTextBlock.ActualHeight.ToString());

MessageBox.Show(objTextBlock.ActualWidth.ToString());

}

No comments:

Post a Comment

How to upload app to macOS

1. Open Terminal Press Cmd (⌘) + Space , type Terminal , and hit Enter . 2. Navigate to Your Build Output Directory Your .app file is likel...