可见性(Windows Phone 7)
抱歉,如果我问一个基本问题!
Customer 类已获取
string Name
和int Age
在 MainPage.xaml.cs 中我有:
ObervableCollection
客户>客户
MainPage.xaml 中的
<Listbox x:Name = "ListCustomer"
ItemsSources = "{Binding Customers}"/>
<Button x:Name = "Button1" Visibility = "Collapsed"/>
:如何在 MainPage.xaml.cs 中设置 Button1 可见性?
if(ListCustomer == null)
<-- 没有数据 Button1 折叠,如果 Listbox (或 Customer - 我不知道) 已获取数据 Button1 可见
//or if(Customers == null)
{
Button1.visibility = visibility.visibled
}
我可以把它放在哪里?
(在“导航至”、“导航自”或“Page_Load”中,某些地方...)
Sorry if I ask a basic question !
Class Customer has got
string Name
andint Age
In MainPage.xaml.cs I have :
ObervableCollection < Customer > Customers
In MainPage.xaml :
<Listbox x:Name = "ListCustomer"
ItemsSources = "{Binding Customers}"/>
<Button x:Name = "Button1" Visibility = "Collapsed"/>
How can i set Button1 visibility in MainPage.xaml.cs?
if(ListCustomer == null)
<-- doesn't have data Button1 is collapsed, if Listbox (or Customer - I don't know)
has got data Button1 is visibled
//or if(Customers == null)
{
Button1.visibility = visibility.visibled
}
Where i can put it ?
(in Navigation To, Navigation From, or Page_Load, some where...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者
上面的代码应该可以帮助您分别使按钮不可见和可见。
最好将其放入
Loaded
事件处理程序中。您可以在此处确保所有 UI 元素均已加载。or
The above code should help you make the button invisible and visible respectively.
It would be best if you could put it in the
Loaded
event handler. This is where you can be sure that all the UI elements are loaded.