我需要能夠避免獲得負值。當窗口瀏覽器調整大小時,我需要datagrid縮小,但不會達到負值以避免出現錯誤。那可能嗎?先謝謝你。如何避免獲得負值?
這裏是我的代碼:
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);
}
}
它的偉大工程。感謝您的幫助!我高度評價它。 – vladc77 2011-05-10 16:50:26