我有一个奇怪的问题。我有两个堆栈面板,每个都有一个按钮,两个堆栈面板的数据上下文相同,并且按钮上的 IsEnabled 属性也设置为相同的属性。然而,一个按钮被禁用,另一个被启用:
StackPanel #1(启用):
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1" Height="23" DataContext="{Binding ElementName=LayoutRoot, Path=DataContext}">
<TextBox Grid.Row="0" Grid.Column="1" Height="23" Width="220" Name="txtBarcode"></TextBox>
<Button IsEnabled="{Binding CanAdd}" cal:Click.Command="{Binding AddBarcodeCommand}" Width="40" Content=". . ." Margin="5,0"></Button>
</StackPanel>
StackPanel #2(已禁用):
<StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" DataContext="{Binding ElementName=LayoutRoot, Path=DataContext}" >
<Button HorizontalAlignment="Right" cal:Click.Command="{Binding ElementName=LayoutRoot, Path=DataContext.SaveCommand}" Grid.Row="3" Grid.Column="1" Height="30" Content="Create Batch" Width="130"></Button>
<Button IsEnabled="{Binding CanAdd}" Height="30" Content="Apply" Width="130" HorizontalAlignment="Right" Margin="5,0"></Button>
</StackPanel>
我在输出窗口中没有看到任何数据绑定错误。有什么我想念的吗?