C# 如何引用我的弹出窗口?
根据我从弗里曼的书《Metro启示录》(顺便说一句,这本书是迄今为止最好的一本书,尽管它的页数不到100页),我正在尝试实现一个设置弹出窗口(弹出窗口) 我有以下相关代码: 具有/是弹出窗口的用户控件:C# 如何引用我的弹出窗口?,c#,windows-8,settings,winrt-xaml,flyout,C#,Windows 8,Settings,Winrt Xaml,Flyout,根据我从弗里曼的书《Metro启示录》(顺便说一句,这本书是迄今为止最好的一本书,尽管它的页数不到100页),我正在尝试实现一个设置弹出窗口(弹出窗口) 我有以下相关代码: 具有/是弹出窗口的用户控件: TimeAndSpaceLines.View.TSLsSettings是类名,而不是实例名。您需要的是实例的名称:hubPageSettingsFlyout。我建议对您的PopusSectionNameIsLightDismissEnabled使用绑定,这样您就不必尝试查找UI元素,而只需检查它
TimeAndSpaceLines.View.TSLsSettings
是类名,而不是实例名。您需要的是实例的名称:hubPageSettingsFlyout
。我建议对您的PopusSectionName
IsLightDismissEnabled
使用绑定,这样您就不必尝试查找UI元素,而只需检查它绑定到的任何属性的值。TimeAndSpaceLines.View.TSLsSettings
是一个类名,而不是实例名。您需要的是实例的名称:hubPageSettingsFlyout
。我建议对您的popupSectionName
IsLightDismissEnabled
使用绑定,这样您就不必尝试查找UI元素,而只需检查它绑定到的任何属性的值。它做得有点不同
我没有创建一个UserControl
,而是创建了一个BasicPage
,然后从主页创建了该页面的一个实例(请参见下面的var mypane=new CreateProvider{Height=Window.Current.Bounds.Height};
)其中CreateProvider
是一个XAML
页面,我将其传递到我的弹出窗口
,就像\u providerPopup.Child=mypane一样代码>。这样试试吧,我想你的UserControl
也可以正常工作。只需将您的用户控件分配给弹出窗口
,如\u Popup.Child=popupSectionName代码>
// Create a Popup window which will contain our flyout.
_providerPopup = new Popup
{
Height = Window.Current.Bounds.Height,
ChildTransitions = new TransitionCollection
{
new PaneThemeTransition
{
Edge =
(SettingsPane.Edge ==
SettingsEdgeLocation.Right)
? EdgeTransitionLocation.Right
: EdgeTransitionLocation.Left
}
}
};
// Add the proper animation for the panel.
// Create a SettingsFlyout the same dimenssions as the Popup.
var mypane = new CreateProvider {Height = Window.Current.Bounds.Height};
// Place the SettingsFlyout inside our Popup window.
_providerPopup.Child = mypane;
// Let's define the location of our Popup.
_providerPopup.SetValue(Canvas.LeftProperty,
SettingsPane.Edge == SettingsEdgeLocation.Right
? (Window.Current.Bounds.Width - SettingsWidth)
: 0);
_providerPopup.SetValue(Canvas.TopProperty, 0);
_providerPopup.IsOpen = true;
它没有什么不同
我没有创建一个UserControl
,而是创建了一个BasicPage
,然后从主页创建了该页面的一个实例(请参见下面的var mypane=new CreateProvider{Height=Window.Current.Bounds.Height};
)其中CreateProvider
是一个XAML
页面,我将其传递到我的弹出窗口
,就像\u providerPopup.Child=mypane一样代码>。这样试试吧,我想你的UserControl
也可以正常工作。只需将您的用户控件分配给弹出窗口
,如\u Popup.Child=popupSectionName代码>
// Create a Popup window which will contain our flyout.
_providerPopup = new Popup
{
Height = Window.Current.Bounds.Height,
ChildTransitions = new TransitionCollection
{
new PaneThemeTransition
{
Edge =
(SettingsPane.Edge ==
SettingsEdgeLocation.Right)
? EdgeTransitionLocation.Right
: EdgeTransitionLocation.Left
}
}
};
// Add the proper animation for the panel.
// Create a SettingsFlyout the same dimenssions as the Popup.
var mypane = new CreateProvider {Height = Window.Current.Bounds.Height};
// Place the SettingsFlyout inside our Popup window.
_providerPopup.Child = mypane;
// Let's define the location of our Popup.
_providerPopup.SetValue(Canvas.LeftProperty,
SettingsPane.Edge == SettingsEdgeLocation.Right
? (Window.Current.Bounds.Width - SettingsWidth)
: 0);
_providerPopup.SetValue(Canvas.TopProperty, 0);
_providerPopup.IsOpen = true;
从“主页”的相关“代码隐藏”中尝试以下操作:
这会有用的 从“主页”的相关“代码隐藏”中尝试:
这会有用的 在SetAndSaveSectionNames中,调用不应该是hubPageSettingsFlyout.PopusSectionName.IsOpen=true吗?当我替换这个时:TimeAndSpaceLines.View.TSLsSettings.PopusSectionName.IsOpen=true;使用此选项:hubpagesetingsflyout.popupSectionName.IsOpen=true。。。我得到,“'TimeAndSpaceLines.View.TSLsSettings.PopusSectionName'由于其保护级别而无法访问”xaml中HubPageSettingsFly的声明是:所以我仍然感到困惑。我可能全搞错了;我必须后退一步,重新开始。在SetAndSaveSectionNames中,调用是否应该为hubPageSettingsFlyout.PopusSectionName.IsOpen=true?当我替换此时:TimeAndSpaceLines.View.TSLsSettings.PopusSectionName.IsOpen=true;使用此选项:hubpagesetingsflyout.popupSectionName.IsOpen=true。。。我得到,“'TimeAndSpaceLines.View.TSLsSettings.PopusSectionName'由于其保护级别而无法访问”xaml中HubPageSettingsFly的声明是:所以我仍然感到困惑。我可能全搞错了;我必须后退一步,重新开始。我相信我正在这样做:设置PaneCommandRequested(设置Spane发件人,设置SpaneCommmandRequestedEventArgs){SettingsCommand=new SettingsCommand(“示例”,“声音选项”,(x)=>{u settingsPopup=new Popup();…var settingsPane=new TSLsSettings();…\u settingsPopup.Child=settingsPane;_settingsPopup.IsOpen=true;});args.Request.ApplicationCommands.Add(cmd);}我相信我是这样做的:在SettingsPaneCommandRequested(SettingsPaneCommandRequestedEventArgs,SettingsPaneCommandRequestedEventArgs){SettingsCommand=new SettingsCommand(“示例”,“声音选项”,(x)=>{U settingsPopup=new Popup();…var settingsPane=new TSLsSettings();…\u settingsPopup.Child=settingsPane;\u settingsPopup.IsOpen=true;});args.Request.ApplicationCommands.Add(cmd);}