我有一個問題,因為幾天可以擺脫。我正在嘗試從子幀導(dǎo)航到另一個框架,事實是,我想我實際上是在導(dǎo)航到它,因為執(zhí)行了C#代碼,但是未加載框架的內(nèi)容(例如Textblock等)...這是我的代碼主框架:<ListView x:Name="listView1" IsItemClickEnabled="True" Grid.Row="1" ItemClick="listView_ItemClickEvent"> <ListView.ItemTemplate> <DataTemplate x:DataType="x:String"> <StackPanel Grid.Column="1" Padding="10 5"> <TextBlock FontSize="20" Padding="0 5 0 0" Text="{Binding ProjCode}" Foreground="Black"/> <TextBlock Padding="10 5 0 5" Text="{Binding Nome}" Foreground="#636567" /> </StackPanel> <TextBlock Name="lblID" Visibility="Collapsed" Text="{Binding id}"/> </DataTemplate> </ListView.ItemTemplate> </ListView> <Frame Name="DetailsFrame" Foreground="{x:Null}" Grid.Column="1" BorderThickness="1,0,0,0" Height="5000"> <Frame.ContentTransitions> <TransitionCollection /> </Frame.ContentTransitions> </Frame>單擊列表,將框架“ ProjectDetails”加載到框架“ DetailsFrame”上。它包含另一個listview:<ListView.ItemTemplate><DataTemplate x:DataType="x:String"> <Border BorderBrush="LightGray" HorizontalAlignment="Stretch" > <Grid BorderBrush="Gray"> <Grid.ColumnDefinitions> *** </Grid.ColumnDefinitions> <Grid.RowDefinitions> *** </Grid.RowDefinitions> <TextBlock Text="{Binding Descrizione}"/> <TextBlock /> <TextBlock Text="{Binding TempoTotale}"/> <TextBlock Name="lblID" Text="{Binding ID}" Visibility="Collapsed" /> </Grid> </Border></DataTemplate>當(dāng)我單擊列表時,從該框架(ProjectDetails)中,我需要用另一個框架更改為“ TaskDetails”。為此任務(wù),我使用了此代碼,但是正如我之前所說,實際的c#代碼寫在執(zhí)行TaskDetail頁面,但未加載Ttextblock等接口Frame.Navigate(typeof(TaskDetails));我應(yīng)該怎么做才能解決這個問題?
2 回答

慕姐4208626
TA貢獻(xiàn)1852條經(jīng)驗 獲得超7個贊
您應(yīng)該P(yáng)rojectDetails在內(nèi)部加載,DetailsFrame并在移至TaskDetails頁面時使用:
DetailsFrame.Navigate(typeof(TaskDetails));
代替 Frame.Navigate(typeof(TaskDetails));
或創(chuàng)建詳細(xì)信息框的靜態(tài)實例,并將其用于導(dǎo)航,如下所示:
在您的主頁中:
public static Frame NavigationFrame;
public MainPage()
{
this.InitializeComponent();
NavigationFrame = DetailFrame;
}
在您要執(zhí)行導(dǎo)航的頁面中,使用以下方法:
MainPage.NavigationFrame.Navigate(typeof(SomeOtherPage));

慕的地10843
TA貢獻(xiàn)1785條經(jīng)驗 獲得超8個贊
不知道為什么或怎么做,但是我花了一段時間解決了問題,只是刪除了“ TaskDetails”頁面并創(chuàng)建了一個新的頁面
- 2 回答
- 0 關(guān)注
- 182 瀏覽
添加回答
舉報
0/150
提交
取消