Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UWP-保存xaml页面的属性(滑块/组合框)_Xaml_User Interface_Uwp_C++ Cx - Fatal编程技术网

UWP-保存xaml页面的属性(滑块/组合框)

UWP-保存xaml页面的属性(滑块/组合框),xaml,user-interface,uwp,c++-cx,Xaml,User Interface,Uwp,C++ Cx,我遇到了以下问题:在我的主xaml页面中,我有一个按钮,可以导航到另一个页面,该页面称为设置,其中还包括应用程序的设置。我使用以下方法跳转到页面: 此->框架->导航(Windows::UI::Xaml::Interop::TypeName(设置::typeid)) 正如您所理解的,我希望UI元素(组合框/滑块)保存它们的属性以备下次使用。即使是下一次启动应用程序,也不需要,只需要在设置页面上进行下一次跳转即可。如果我从设置返回主页,然后再次返回设置,组合框和滑块的值将重置。我需要将它们保存为程

我遇到了以下问题:在我的主xaml页面中,我有一个按钮,可以导航到另一个页面,该页面称为设置,其中还包括应用程序的设置。我使用以下方法跳转到页面:

此->框架->导航(Windows::UI::Xaml::Interop::TypeName(设置::typeid))

正如您所理解的,我希望UI元素(组合框/滑块)保存它们的属性以备下次使用。即使是下一次启动应用程序,也不需要,只需要在设置页面上进行下一次跳转即可。如果我从设置返回主页,然后再次返回设置,组合框和滑块的值将重置。我需要将它们保存为程序逻辑


在我的c++桌面应用程序中,我使用注册表条目来保存它,但这在uwp中是不太可能的,并且不是最简单的解决方案。在Java中,我将使用一个全局静态变量来保存值并绑定到UI元素。我如何在UWP中实现这一点?

您可以使用。使用该属性,您可以将页面状态存储在应用程序的缓存中。
您可以在页面的xaml标记中使用它,也可以在页面代码隐藏的构造函数中设置它。您可以找到属性的可能值

示例XAML:

 <Page
    x:Class="Foo.Namespace.SettingsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Foo.Namespace"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    NavigationCacheMode="Enabled">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    </Grid>
</Page>
 public sealed partial class SettingsPage : Page
    {
        public SettingsPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Enabled;
        }
    }