2012-04-18 48 views
0

我有一個C#WPF應用程序那裏有在上面的一些按鈕來執行像查表或維修此功能:選項卡按鈕變爲禁用

<Border Grid.Row="0" CornerRadius="5" BorderBrush="AliceBlue" Margin="10" VerticalAlignment="Top" > 
     <StackPanel Orientation="Horizontal" Height="35" > 
      <Button Content="Upload File" Margin="0,0,3,0" Command="{Binding CmdUploadFileCtrl}" Width="100"></Button> 
      <Button Content="Medicine Price" Margin="0,0,3,0" Command="{Binding CmdMedicinePriceCtrl}" Width="100"></Button> 
      <Button Content="NDC Discounts" Margin="0,0,3,0" Command="{Binding CmdNDCDiscountCtrl}" Width="100"></Button> 
      <Button Content="Facility" Margin="0,0,3,0" Command="{Binding CmdFacilityCtrl}" Width="100"></Button> 
     </StackPanel> 
    </Border> 

<sdk:DataGrid 
         Grid.Row="1" x:Name="dgFacility" 
         SelectionMode="Single" 
         SelectedItem="{Binding Path=SelectedItemFacility, Mode=TwoWay}" 
         ItemsSource="{Binding Path=LstFacility, Mode=TwoWay}" 
         AutoGenerateColumns="False" 
         HorizontalAlignment="Stretch" 
         VerticalAlignment="Stretch" 
         AllowDrop="False"> 

當用戶按下設備標籤不言而喻那裏,但是當然後試圖'上傳文件'該按鈕被禁用。我怎樣才能防止這種禁用?

+0

你的XAML是什麼樣的?你有什麼樣的綁定? – 2012-04-18 16:20:39

+0

Bleep bloop修復了您的代碼格式。請在提交問題前查看預覽。 – jadarnel27 2012-04-18 16:21:53

回答

1

由於按鈕綁定到命令,應該有代碼(某處)確定何時啓用/禁用按鈕。

根據使用什麼類型的命令,您可能會有一個名爲類似CanUploadFileCtrl或CmdUploadFileCtrl_CanExecute的方法,它返回true/false。

+0

2012-04-19 13:34:52

+0

and here cmdUploadFile = new DelegateCommand(UploadFile); – 2012-04-19 13:49:12