WPF 单选题页面布局

 1 <DockPanel>
 2         <TextBlock Text="满意度评价"  FontSize="50" Background="White" TextAlignment="Center" FontFamily="华文楷体" DockPanel.Dock="Top"/>
 3         <StackPanel DockPanel.Dock="Bottom" >
 4             <Button Content="提交"  FontSize="50" FontFamily="华文楷体"  Command="{Binding ConfirmCommand}"  Width="150" Background="#53C626"/>
 5         </StackPanel>
 6         <DataGrid Name="Project" FontFamily="华文楷体" AutoGenerateColumns="False" GridLinesVisibility="None"  
 7             ItemsSource="{Binding Collection}" IsEnabled="True" CanUserAddRows="False" Height="Auto" >
 8             <DataGrid.Columns>
 9                 <DataGridTextColumn Header="序号"  Width="*" Binding="{Binding No}" FontSize="24" IsReadOnly="True">
10                     <DataGridTextColumn.HeaderStyle>
11                         <Style TargetType="{x:Type DataGridColumnHeader}">
12                             <Style.Setters>
13                                 <Setter Property="FontSize" Value="35"/>
14                                 <Setter Property="HorizontalContentAlignment" Value="Center"/>
15                                 <Setter Property="Background" Value="#53C626"/>
16                             </Style.Setters>
17                         </Style>
18                     </DataGridTextColumn.HeaderStyle>
19                 </DataGridTextColumn>
20                 <DataGridTextColumn Header="项目"  Width="6*" Binding="{Binding Ques}" FontSize="24" IsReadOnly="True">
21                     <DataGridTextColumn.HeaderStyle>
22                         <Style TargetType="{x:Type DataGridColumnHeader}">
23                             <Style.Setters>
24                                 <Setter Property="FontSize" Value="35"/>
25                                 <Setter Property="HorizontalContentAlignment" Value="Center"/>
26                                 <Setter Property="Background" Value="#53C626"/>
27                             </Style.Setters>
28                         </Style>
29                     </DataGridTextColumn.HeaderStyle>
30                 </DataGridTextColumn>
31                 <DataGridTemplateColumn Header="满意度" Width="3*" IsReadOnly="False" CellTemplate="{StaticResource Result}">
32                     <DataGridTemplateColumn.HeaderStyle>
33                         <Style TargetType="{x:Type DataGridColumnHeader}">
34                             <Style.Setters>
35                                 <Setter Property="FontSize" Value="35"/>
36                                 <Setter Property="HorizontalContentAlignment" Value="Center"/>
37                                 <Setter Property="Background" Value="#53C626"/>
38                             </Style.Setters>
39                         </Style>
40                     </DataGridTemplateColumn.HeaderStyle>
41                 </DataGridTemplateColumn>
42             </DataGrid.Columns>
43         </DataGrid>
44 
45         <!--<DataGrid  Name="Result" FontSize="45" FontFamily="华文楷体" AutoGenerateColumns="False" GridLinesVisibility="None"  
46              IsEnabled="True"  Margin="0,0,0,-0.2" ItemsSource="{Binding Results}">
47                 <DataGrid.Columns>
48                     <DataGridCheckBoxColumn Header="满意" Width="*" Binding="{Binding Satisfy,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  IsReadOnly="False" >
49                         <DataGridCheckBoxColumn.ElementStyle >
50                             <Style TargetType="CheckBox"/>
51                         </DataGridCheckBoxColumn.ElementStyle>
52                     </DataGridCheckBoxColumn>
53                     <DataGridCheckBoxColumn Header="一般" Width="*" Binding="{Binding Common,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"     IsReadOnly="False">
54                         <DataGridCheckBoxColumn.ElementStyle >
55                             <Style TargetType="CheckBox" />
56                         </DataGridCheckBoxColumn.ElementStyle>
57                     </DataGridCheckBoxColumn>
58                     <DataGridCheckBoxColumn Header="不满意" Width="*" Binding="{Binding UnSatisfy,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  IsReadOnly="False">
59                         <DataGridCheckBoxColumn.ElementStyle >
60                             <Style TargetType="CheckBox" />
61                         </DataGridCheckBoxColumn.ElementStyle>
62                     </DataGridCheckBoxColumn>
63                 </DataGrid.Columns>
64             </DataGrid>-->
65     </DockPanel>
66 
67 #静态资源
68 <DataTemplate x:Key="Result">
69         <StackPanel Margin="20,0,20,0" Orientation="Horizontal" Height="Auto" >
70             <RadioButton IsChecked="{Binding Path = Satisfy, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Content="满意" FontSize="24"/>
71             <RadioButton IsChecked="{Binding Path = Common,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Content="一般" FontSize="24"/>
72             <RadioButton IsChecked="{Binding Path = UnSatisfy,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Content="不满意" FontSize="24"/>
73         </StackPanel>
74     </DataTemplate>
75   注:xaml页面数据向viewmodel传递时,需要定义传递方式Mode,默认单向传递,即后台向页面传递

 

posted @ 2019-09-05 10:13  土豆2号  阅读(214)  评论(0编辑  收藏  举报