我需要能夠將邊框的可見性設置爲可見10秒。該邊框駐留在MainPage.xaml中,它是Content.xaml的父級。訣竅是我需要通過單擊可從Content.xaml訪問的ContextMenu項來更改邊框的可見性,該項作爲UserControl加載到MainPage.xaml中。它也應該有條件地基於數據網格中的單元格值。我在Content.xaml中建立了一個方法,它應該有條件地改變MainPage.xaml中邊界的可見性。由於邊界超出了範圍,我需要找到一種方法來連接它。如何在Silverlight中跨頁面運行方法?
代碼以基於在數據網格中單元格的值的內容設置的可見性:
private void Delete(object sender, RoutedEventArgs e)
{
Packages_DataViewModel currentItem = MasterTile.SelectedItem as Packages_DataViewModel;
if (currentItem.Status != "has content")
{
this.MainPageBorder.Visibility = Visibility.Visible;
}
else
{
mv.DeletePackagesItem((Packages_DataViewModel)(MasterTile.SelectedItem));
}
}
我還需要運行我在Content.xaml用於從在一個的MainPage按鈕修改數據網格的內容的方法的.xaml。任何想法都非常感謝!
代碼更新單元格的值:
private void Status(object sender, RoutedEventArgs e)
{
Packages_DataViewModel currentItem = MasterTile.SelectedItem as Packages_DataViewModel;
currentItem.Status = "has content";
this.MainPageBorder.Visibility = Visibility.Collapsed;
}
謝謝!太好了。這對我來說能夠訪問Page1中的方法。我想知道如何正確應用'Application.Current.RootVisual'。我把它放在構造函數中。我嘗試過,但不允許訪問該對象。我想讓'grdMainPage_SystemMessages_Blue'對象可用。請讓我知道如何正確使用RootVisual。再次感謝你。 – vladc77 2011-03-28 19:04:17