Dot-Net

WPF中復選框左側的文本?

  • July 4, 2013

將復選框內容(文本)放在復選框本身左側的最簡單方法是什麼?

最大化“輕鬆”和“正確性”的解決方案是製作一個RightToLeft包含內容的複選框LeftToRight

<CheckBox FlowDirection="RightToLeft">
   <TextBlock FlowDirection="LeftToRight" Text="CheckBox Content:" />
</CheckBox>

或者,如果您想要一種風格:

<Style TargetType="CheckBox">
   <Setter Property="FlowDirection" Value="RightToLeft" />
   <Setter Property="ContentTemplate">
       <Setter.Value>
           <DataTemplate>
               <ContentControl FlowDirection="LeftToRight" Content="{Binding}" />
           </DataTemplate>
       </Setter.Value>
   </Setter>
</Style>

引用自:https://stackoverflow.com/questions/17465867