C# 如何在特定透视项目中覆盖弹出窗口
这是一个有趣的问题,但我只想在我的数据透视页面中的单个数据透视项上覆盖一个弹出窗口,并且只有在发生一定数量的“事件”之后(这些事件是一个单击事件,例如单击50次)。我的数据透视项中有一个列表框,但我想知道在满足条件后,如何在其上覆盖一个弹出窗口 XAMLC# 如何在特定透视项目中覆盖弹出窗口,c#,windows-phone-7,windows-phone-8,popup,C#,Windows Phone 7,Windows Phone 8,Popup,这是一个有趣的问题,但我只想在我的数据透视页面中的单个数据透视项上覆盖一个弹出窗口,并且只有在发生一定数量的“事件”之后(这些事件是一个单击事件,例如单击50次)。我的数据透视项中有一个列表框,但我想知道在满足条件后,如何在其上覆盖一个弹出窗口 XAML 此外,我还需要以某种方式检索弹出窗口的结果值(从“确定”或“取消”按钮),并根据该结果调用ApplySelectedEffectAndSaveAsync()方法或返回上一个数据透视项(或上一页)。覆盖的数据透视项实际上是索引1,在它之前还有另一
此外,我还需要以某种方式检索弹出窗口的结果值(从“确定”或“取消”按钮),并根据该结果调用
ApplySelectedEffectAndSaveAsync()
方法或返回上一个数据透视项(或上一页)。覆盖的数据透视项实际上是索引1,在它之前还有另一个索引为0的数据透视项。您似乎正在查找MessageBox.Show
。此方法显示一个带有您自己的标题、文本以及OK或OK和cancel按钮的弹出窗口。该方法返回一个MessageBoxResult
值,该值为MessageBoxResult.OK
或MessageBoxResult.Cancel
这是在代码中应该如何实现的:
private void BuildLocalizedApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();
ApplicationBarIconButton saveButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/save.png", UriKind.Relative));
saveButton.Text = AppResources.EditPage_ApplicationBar_Save;
saveButton.Click += saveButton_Click;
ApplicationBar.Buttons.Add(saveButton);
}
void saveButton_Click(object sender, EventArgs e)
{
Settings.SavedCount.Value += 1;
if(Settings.SavedCount.Value > 50)
{
if(MessageBox.Show("Message", "Title", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
// Action for "OK"
else
// Action for "Cancel"
}
}
您可以从代码隐藏中管理MyPopup(您可以计算点击次数或事件并设置
MyPopup.IsOpen=true
)我熟悉MessageBox,但出于我的目的,我需要更广泛一点的内容。我希望将弹出窗口严格放置在数据透视项上,并在弹出窗口内使用自定义背景和前景、边框、图像等设置主题。
private void BuildLocalizedApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();
ApplicationBarIconButton saveButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/save.png", UriKind.Relative));
saveButton.Text = AppResources.EditPage_ApplicationBar_Save;
saveButton.Click += saveButton_Click;
ApplicationBar.Buttons.Add(saveButton);
}
void saveButton_Click(object sender, EventArgs e)
{
Settings.SavedCount.Value += 1;
if(Settings.SavedCount.Value > 50)
//Display Popup
ApplySelectedEffectAndSaveAsync();
}
private void BuildLocalizedApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();
ApplicationBarIconButton saveButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/save.png", UriKind.Relative));
saveButton.Text = AppResources.EditPage_ApplicationBar_Save;
saveButton.Click += saveButton_Click;
ApplicationBar.Buttons.Add(saveButton);
}
void saveButton_Click(object sender, EventArgs e)
{
Settings.SavedCount.Value += 1;
if(Settings.SavedCount.Value > 50)
{
if(MessageBox.Show("Message", "Title", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
// Action for "OK"
else
// Action for "Cancel"
}
}
<phone:PivotItem ...>
<Grid>
<ListBox .../>
<Popup Name="MyPopup" IsOpen="false"/>
</Grid>
</phone:PivotItem>