是否可以在通用应用中将参数值从Frame发送到ContentDialog
?这就是我从MainPage中调用ContentDialog
“MycontentDialog”的方法:
private async void ConxBtn_Click(object sender, RoutedEventArgs e)
{
await new MycontentDialog().ShowAsync();
}
更新: 我像这样使用了“DataContext”:
bool stateConnexion=true;
private async void ConxBtn_Click(object sender, RoutedEventArgs e)
{
ContentDialog cd = new MycontentDialog();
cd.DataContext = stateConnexion;
await cd.ShowAsync();
}
现在从MycontentDialog
代码开始,我如何访问stateConnexion
值?
UPDATE2: 我已使用此回复Passing a string parameter to a textblock
就我而言:
MainPage.xaml.cs中:
bool stateConnexion=true;
private async void ConxBtn_Click(object sender, RoutedEventArgs e)
{
ContentDialog cd = new MycontentDialog();
cd.DataContext = new
{
testbool = stateConnexion
};
await cd.ShowAsync();
}
MycontentDialog.xaml.cs:
private bool testbool=false;
public LocalisationPopUP()
{
this.InitializeComponent();
}
private new void PrimaryButtonClick(object sender, RoutedEventArgs e)
{
bool t = testbool;
.....//traitment when I get value
}
我现在的问题是我总是为testbool
变量
有什么想法吗?