【发布时间】:2012-10-15 15:19:51
【问题描述】:
我有一个按钮,当我使用 datacontext 和命令时,命令不起作用:
<Button DataContext="{Binding horaires}" Style="{StaticResource RefreshAppBarButtonStyle}" AutomationProperties.Name="{Binding HomeAppBarTitle, Converter={StaticResource StringResourceConverter}}" Command="{Binding RefreshCommand}" ></Button>
当我删除数据上下文并手动设置名称时:
<Button Style="{StaticResource RefreshAppBarButtonStyle}" AutomationProperties.Name="Actualiser" Command="{Binding RefreshCommand}" ></Button>
可能是什么问题?
最好的问候
【问题讨论】:
-
你到底想用这个做什么:DataContext="{Binding horaires}" ?
-
我尝试用它来改变属性:AutomationProperties.Name 用法语写“Actualiser”,用英文写“Refresh”,“HomeAppBarTitle”包含这个值
-
在您的代码隐藏中是
RefreshCommand吗? -
refreshcommand 在我的 viewModel 中:class HorairesViewModel { public HorairesModel horaires { get;放; } 公共 ICommand RefreshCommand { 获取;私人套装; }
-
绑定你的按钮的DataContext看起来还是很奇怪。
标签: xaml windows-8 microsoft-metro