有人能告诉我如何动态地执行以下操作。我提到了很多网站。但没有任何帮助我。
<phone:PhoneApplicationPage.Resources>
<shell:ApplicationBar x:Key="DefaultAppBar" IsVisible="True">
<shell:ApplicationBarIconButton x:Name="mnuAdd" IconUri="/icons/appbar.add.rest.png" IsEnabled="True" Text="Add" Click="mnuAdd_Click"/>
</shell:ApplicationBar>
<shell:ApplicationBar x:Key="SingleSelectionAppBar" IsVisible="True">
<shell:ApplicationBarIconButton x:Name="mnuPin" IconUri="/icons/appbar.pushpin.png" IsEnabled="True" Text="Pin" Click="mnuPin_Click" />
<shell:ApplicationBarIconButton x:Name="mnuDelete" IconUri="/icons/appbar.delete.rest.png" IsEnabled="True" Text="Delete" Click="mnuDelete_Click"/>
<shell:ApplicationBarIconButton x:Name="mnuEdit" IconUri="/icons/appbar.edit.rest.png" IsEnabled="True" Text="Edit" Click="mnuEdit_Click"/>
</shell:ApplicationBar>
<shell:ApplicationBar x:Key="MultiSelectionAppBar" IsVisible="True">
<shell:ApplicationBarIconButton x:Name="mnuDeleteMulti" IconUri="/icons/appbar.delete.rest.png" IsEnabled="True" Text="Delete" Click="mnuDelete_Click"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.Resources>
我们可以get the resource dynamically
如下。但如何添加到runtine
ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["SingleSelectionAppBar"];
答案 0 :(得分:0)
简单的解决方案,但我搜索不好。无论如何在这里添加解决方案
<强>语法:强>
Application.Current.Resources.Add (name, value)
<强>示例强>
Application.Current.Resources.Add("DefaultAppBar", AppBar1);
Application.Current.Resources.Add("SingleSelectionAppBar", AppBar2);
Application.Current.Resources.Add("MultiSelectionAppBar", AppBar3);