根据我从弗里曼的书“Metro Revealed”中收集到的信息(顺便说一句,这是迄今为止最好的书,尽管它的重量不到 100 页),我正在尝试实现一个设置弹出窗口(弹出窗口)。
我有这个相关的代码:
具有/是弹出窗口的用户控件:
<UserControl
x:Class="TimeAndSpaceLines.View.TSLsSettings"
. . .
<Popup x:Name="popupSectionName" IsLightDismissEnabled="True" >
. . .
</Popup>
</UserControl>
“主”页面的 xaml:
<common:LayoutAwarePage
x:Name="pageRoot"
. . .
xmlns:settingsflyout="using:TimeAndSpaceLines.View"
. . .
</Grid>
<settingsflyout:TSLsSettings x:Name="hubPageSettingsFlyout"/>
<VisualStateManager.VisualStateGroups>
. . .
“主”页面的相关“代码隐藏”:
public ItemsPage()
{
InitializeComponent();
SettingsPane.GetForCurrentView().CommandsRequested += OnSettingsPaneCommandRequested;
}
private void OnSettingsPaneCommandRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
// Add the commands one by one to the settings panel
args.Request.ApplicationCommands.Add(new SettingsCommand("commandSetSection1Name",
"Change the name of Section 1", SetAndSaveSectionNames));
. . .
}
但是,当我尝试以这种方式打开它时:
private void SetAndSaveSectionNames(IUICommand command)
{
TimeAndSpaceLines.View.TSLsSettings.popupSectionName.IsOpen = true;
. . .
}
我受到了欢迎:
An object reference is required for the non-static field, method, or property
'TimeAndSpaceLines.View.TSLsSettings.popupSectionName'
和:
'TimeAndSpaceLines.View.TSLsSettings.popupSectionName' is inaccessible due to its protection level
然而popupSectionName
不是一个类,它所在的类是公共的。我该怎么办?