【发布时间】:2011-05-09 21:40:27
【问题描述】:
我想知道我使用的代码有什么问题。我试图通过下面提供的代码来限制基于浏览器窗口的数据网格的高度调整大小。也许,有更好的方法来做到这一点。非常感谢任何建议。
当我调整窗口大小超过我得到错误。
*System.ArgumentException 未被用户代码处理 Message=Value 不在预期范围内。 堆栈跟踪: 在 MS.Internal.XcpImports.CheckHResult(UInt32 小时) 在 MS.Internal.XcpImports.SetValue(IManagedPeerBase obj,DependencyProperty 属性,Double d) 在 System.Windows.DependencyObject.SetValue(DependencyProperty 属性,双 d) 在 System.Windows.FrameworkElement.set_Height(双值) 在 SilverlightResizeTest.Content_Resized(Object sender, EventArgs e) 在 System.Windows.Interop.Content.FireResized(对象发送者,EventArgs args) 在 System.Windows.Interop.SilverlightHost.FireResized(对象发送者,EventArgs args) 在 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj,IntPtr unmanagedObjArgs,Int32 argsTypeIndex,Int32 actualArgsTypeIndex, 字符串事件名称) 内部异常:*
代码:
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);
}
}
【问题讨论】:
标签: silverlight datagrid