1

I am new to Windows 8 development. i am following the tutorial provided by the Windows 8 team and i have run across some problem.

Can someone please tell me where i should insert the following code block explained in the tutorial. (In step 2)

   Windows.Storage.ApplicationDataContainer roamingSettings = 
            Windows.Storage.ApplicationData.Current.RoamingSettings;
        roamingSettings.Values["userName"] = nameInput.Text;

I was looking at MainPage.xaml.cs but it doesn't have any definition of a TextField. So where should i add this code block.

4

1 回答 1

1

该定义位于 MainPage.xaml 而不是 MainPage.xaml.cs:

            <TextBox x:Name="nameInput" Width="300" HorizontalAlignment="Left"
                     TextChanged="NameInput_TextChanged"/>

MainPage.xaml.cs 是 xaml 的部分类,因此在 xaml 中声明的任何控件都可以从 .cs 文件中获得。

请参阅此处的完整示例。

于 2012-12-26T17:29:11.347 回答