我有疑问,
1.我设计了一个用于添加组织的页面
2.我可以添加数据并将其成功发布到服务器上。
3.转而我需要更新我的组织细节..
所以我需要使用添加组织的相同设计页面来更新我的详细信息,是否可以使用相同的页面或需要设计其他页面来更新详细信息..
所以请建议我做什么..
我的Xaml设计代码..
<Grid x:Name="ContentPanel" Margin="12,157,12,4" Grid.RowSpan="2">
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,67,0,0" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" Width="65"/>
<TextBox x:Name="txt_name" HorizontalAlignment="Left" Height="73" Margin="121,42,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="PersonalFullName"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,115,0,0" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top" Width="75"/>
<TextBox x:Name="txt_address" HorizontalAlignment="Left" Height="78" Margin="121,110,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="PostalAddress"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,197,0,0" TextWrapping="Wrap" Text="City" VerticalAlignment="Top" Width="65"/>
<TextBox x:Name="txt_city" HorizontalAlignment="Left" Height="73" Margin="121,178,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="AddressCity"/>
</Grid>
答案 0 :(得分:3)
无需制作2页。 只是 从调用添加和更新功能的相应页面发送查询字符串并进行这样的导航
导航以添加详细信息
string paramAdd="Add"
NavigationService.Navigate(new Uri("/View/Page/AddDetails.xaml?parameter="+paramAdd,UriKind.RelativeOrAbsolute))
导航更新详细信息
string paramUpdate="Update"
NavigationService.Navigate(new Uri("/View/Page/AddDetails.xaml?parameter="+paramUpdate,UriKind.RelativeOrAbsolute))
没有使页面的OnNavigatedTo事件,并写下这些代码行。
if (NavigationContext.QueryString.ContainsKey("parameter"))
{
string function= (NavigationContext.QueryString["parameter"]).ToString();
if(function=="Add")
{
//Action for add
}
else if(function=="Update")
{
//Action for update.
}
}
希望这有效,因为它对我有用。