2016-09-22 27 views
0

我有一個單選按鈕控件和一些依賴控件,我希望根據所選單選按鈕啓用或禁用該控件。根據父項屬性爲嵌套LayoutGroup設置IsEnabled

要做到這一點,我試圖綁定IsEnabledLayoutGroup s與​​。它雖然沒有工作。

我的XAML看起來像這樣

<Grid> 
    <dxlc:LayoutGroup Orientation="Horizontal"> 
     <dxe:ListBoxEdit ShowBorder="False" StyleSettings="{dxe:RadioListBoxEditStyleSettings}" HorizontalContentAlignment="Stretch"> 
      <dxe:ListBoxEditItem Name="radioButtonA" IsSelected="{Binding IsASelected, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"> 
       <dxlc:LayoutGroup> 
        <dxlc:LayoutItem Label="A"> 
         <dxlc:LayoutGroup Name="aLayoutGroup" IsEnabled="{Binding IsSelected, ElementName=radioButtonA}"> 
          <dxlc:LayoutItem Label="Date A"> 
           <dxe:DateEdit EditValue="{Binding DateA, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/> 
          </dxlc:LayoutItem> 
          <dxlc:LayoutItem Label="Text A"> 
           <dxe:TextEdit EditValue="{Binding TextA, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/> 
          </dxlc:LayoutItem> 
         </dxlc:LayoutGroup> 
        </dxlc:LayoutItem> 
       </dxlc:LayoutGroup> 
      </dxe:ListBoxEditItem> 
      <dxe:ListBoxEditItem Name="radioButtonB" IsSelected="{Binding IsASelected, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"> 
       <dxlc:LayoutGroup> 
        <dxlc:LayoutItem Label="B"> 
         <dxlc:LayoutGroup Name="bLayoutGroup" IsEnabled="{Binding IsSelected, ElementName=radioButtonB}"> 
          <dxlc:LayoutItem Label="Date B"> 
           <dxe:DateEdit EditValue="{Binding DateB, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/> 
          </dxlc:LayoutItem> 
          <dxlc:LayoutItem Label="Text B"> 
           <dxe:TextEdit EditValue="{Binding TextB, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/> 
          </dxlc:LayoutItem> 
         </dxlc:LayoutGroup> 
        </dxlc:LayoutItem> 
       </dxlc:LayoutGroup> 
      </dxe:ListBoxEditItem> 
     </dxe:ListBoxEdit> 
    </dxlc:LayoutGroup> 
</Grid> 

順便說一句,如果我移動LayoutGroup S中ListBoxEdit控制之外,它按預期工作。然後問題是我不知道如何將單選按鈕與從屬控件對齊。如果有人能夠幫助我正確對準這些問題,那麼我認爲這種解決方案也會起作用。

回答

0

由於我不是動態生成單選按鈕,因此我決定不使用ListBoxEdit,而只是在我的佈局中放置RadioButton元素。我需要將IsSelected綁定爲IsChecked,但除此之外,它的工作方式幾乎相同。

相關問題