zoukankan      html  css  js  c++  java
  • CheckBox多选

    前台:

     1   <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
     2             <CheckBox Name="cbSampleYes" Content="Yes" />
     3             <CheckBox Name="cbSampleSure" Content="I'm sure" />
     4             <TextBlock HorizontalAlignment="Center" Margin="0,20,0,0" FontSize="28">
     5             <TextBlock.Style>
     6                 <Style TargetType="TextBlock">
     7                     <Setter Property="Text" Value="Unverified" />
     8                     <Setter Property="Foreground" Value="Red" />
     9                     <Style.Triggers>
    10                         <MultiDataTrigger>
    11                             <MultiDataTrigger.Conditions>
    12                                 <Condition Binding="{Binding ElementName=cbSampleYes, Path=IsChecked}" Value="True" />
    13                                 <Condition Binding="{Binding ElementName=cbSampleSure, Path=IsChecked}" Value="True" />
    14                             </MultiDataTrigger.Conditions>
    15                             
    16                             <Setter Property="Text" Value="Verified" />
    17                             <Setter Property="Foreground" Value="Green" />
    18                         </MultiDataTrigger>
    19                     </Style.Triggers>
    20                 </Style>
    21             </TextBlock.Style>
    22             </TextBlock>
    23         </StackPanel>

    后台:

     1         private void cbAllFeatures_CheckedChanged(object sender, RoutedEventArgs e)
     2         {
     3             bool newVal = (cbAllFeatures.IsChecked == true);
     4             cbFeatureAbc.IsChecked = newVal;
     5             cbFeatureXyz.IsChecked = newVal;
     6             cbFeatureWww.IsChecked = newVal;
     7         }
     8 
     9         private void cbFeature_CheckedChanged(object sender, RoutedEventArgs e)
    10         {
    11             cbAllFeatures.IsChecked = null;
    12             if ((cbFeatureAbc.IsChecked == true) && (cbFeatureXyz.IsChecked == true) && (cbFeatureWww.IsChecked == true))
    13                 cbAllFeatures.IsChecked = true;
    14             if ((cbFeatureAbc.IsChecked == false) && (cbFeatureXyz.IsChecked == false) && (cbFeatureWww.IsChecked == false))
    15                 cbAllFeatures.IsChecked = false;
    16         }
  • 相关阅读:
    RA-Embedding-based Retrieval in Facebook Search
    RA-Recommending What Video to Watch Next: A Multitask Ranking System
    家事杂谈-2
    工作体会-3
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
  • 原文地址:https://www.cnblogs.com/ants_double/p/5366423.html
Copyright © 2011-2022 走看看