I’d like to find out what is wrong with the code I use. I am trying to limit the height resize of the datagrid based on browser window by the code behind provided below. Perhaps, there is a better way of doing that. Any advice is highly appreciated.
When I resize the window too much than I am getting error.
*System.ArgumentException was unhandled by user code Message=Value does not fall within the expected range. StackTrace: at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, Double d) at System.Windows.DependencyObject.SetValue(DependencyProperty property, Double d) at System.Windows.FrameworkElement.set_Height(Double value) at SilverlightResizeTest.Content_Resized(Object sender, EventArgs e) at System.Windows.Interop.Content.FireResized(Object sender, EventArgs args) at System.Windows.Interop.SilverlightHost.FireResized(Object sender, EventArgs args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName) InnerException:*
The code:
public SilverlightResizeTest()
{
InitializeComponent();
// Set the height for the DataGrid when the browser window changes size
App.Current.Host.Content.Resized += new System.EventHandler(Content_Resized);
// Set the initial height for the DataGrid
double x = App.Current.Host.Content.ActualHeight;
if (x != 0)
{
DataGrid.Height = (x - 485.0);
}
}
void Content_Resized(object sender, System.EventArgs e)
{
// Set the height for the DataGrid when the browser window changes size
double x = App.Current.Host.Content.ActualHeight;
if (x != 0)
{
DataGrid.Height = (x - 485.0);
}
}