How to get the Actual Width of a Grid Column whose width is Auto.
-
Hi, I want to get the actual width of a grid column whose width is set to Auto at run time. I need to dynamically add a control to the grid and want to set its marign depends on some value. So i want to get the Actual column width dynamically. thanks, Nitheesh
Jose Jo Martin http://www.simpletools.co.in
-
Hi, I want to get the actual width of a grid column whose width is set to Auto at run time. I need to dynamically add a control to the grid and want to set its marign depends on some value. So i want to get the Actual column width dynamically. thanks, Nitheesh
Jose Jo Martin http://www.simpletools.co.in
How about the ActualWidth property? :-D
-
How about the ActualWidth property? :-D
Hi, thank you for the reply. But when the minWidth is set then only the ActualWidth gives the value and if the Width property is set then the ActualWidth is 0 and Width.Value returns the correct width. But when the Column width='Auto' both properties returns 0. Any idea. thanks Nitheesh
Jose Jo Martin http://www.simpletools.co.in
-
Hi, I want to get the actual width of a grid column whose width is set to Auto at run time. I need to dynamically add a control to the grid and want to set its marign depends on some value. So i want to get the Actual column width dynamically. thanks, Nitheesh
Jose Jo Martin http://www.simpletools.co.in
Hi, try to add an SizeChanged event to you grid. The SizeChangedEventArgs have a property NewSize. And with this you can easy calculate the grid column width GridColumnWidth = (windowWidth / 100) * GridColumnProcent
public partial class Window1 : Window
{
double windowWidth;public Window1() { InitializeComponent(); this.SizeChanged += new SizeChangedEventHandler(Window1\_SizeChanged); } void Window1\_SizeChanged(object sender, SizeChangedEventArgs e) { windowWidth = e.NewSize.Width; } }