我想在我的应用程序中标准化弹出窗口。因此,我为其创建了一个用户控件,并按如下所示引用它:
<!--<Popup x:Name="LoginPopup" Grid.ColumnSpan="2" Grid.RowSpan="2" Height="768" Width="1366" IsOpen="False">-->
<uc:StandardDialog Name="StandardDialog" Height="768" Width="1366" Grid.ColumnSpan="2">
.
.
.
</uc:StandardDialog>
<!--</Popup>-->
并在后面的代码中:
private void LoginClicked(object sender, RoutedEventArgs e)
{
StandardDialog.IsOpen = true;
//LoginPopup.IsOpen = true;
}
private void CloseLoginPopup(object sender, RoutedEventArgs e)
{
StandardDialog.IsOpen = false;
//LoginPopup.IsOpen = false;
}
但是,此操作失败并显示以下错误,该错误指向上面的行:
错误1名称'StandardDialog'在当前不存在
上下文C:\ NSyncHg \ MyApp.WinRT \ Views \ TestVisualAwarePage.xaml.cs 46 13 MyApp.WinRT
但是,如果我取消注释上面的弹出窗口并恢复为内置弹出窗口,则所有内容都会编译并运行。
我究竟做错了什么?
参考方案
您需要使用x:Name
属性,而不仅仅是Name
。
<uc:StandardDialog x:Name="StandardDialog" ...
Windows Store应用程序不会为指定了Name
的对象自动创建一个字段。如果要创建一个命名字段并将其提供给后面的代码,则必须使用x:Name
属性。
我正在使用Retrofit来获取JSON答复。这是我实施的一部分-@GET("/api/report/list") Observable<Bills> listBill(@Query("employee_id") String employeeID); 而条例草案类是-public static class…
Windows Phone WNS通知导航到特定页面 - c#它是Windows运行时,Windows Phone专用项目。我正在使用Azure和Azure通知中心。所以我的问题是,有谁愿意如何导航到某些特定页面并发送ID等参数。这是我的吐司模板,如字符串中所述: var toast = @"<toast><visual><binding template=""…
改造正在返回一个空的响应主体 - java我正在尝试使用Retrofit和Gson解析一些JSON。但是,我得到的响应机构是空的。当我尝试从对象中打印信息时,出现NullPointerException。我确保URL正确,并且我也确保POJO也正确。我正在使用jsonschema2pojo来帮助创建POJO类。这是我要解析的JSON{ "?xml": { "@versi…
Mongo汇总 - javascript我的收藏中有以下文件{ "_id": ObjectId("54490b8104f7142f22ecc97f"), "title": "Sample1", "slug": "samplenews", "cat": …
Windows 8 Metro应用程序的图表 - c#As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely …