需求:使用C1FlexGrid绑定数据,各列均只读。
问题:在C1FlexGrid中设置IsReadOnly="True",或者在Column中设置IsReadOnly="True",列表的CheckBox列(“排单”列)仍然可以编辑;代码如下
- <c1:C1FlexGrid Name="C1FlexGrid" Grid.Row="1" AutoGenerateColumns="False" AllowAddNew="False"
- IsReadOnly="True" Style="{StaticResource Green}" BorderThickness="1"
- SelectionMode="Row" MaxRowHeight="20"
- ItemsSource="{Binding List,IsAsync=True}" SelectedItem="{Binding CurrentItem,Mode=TwoWay}">
- <i:Interaction.Triggers>
- <i:EventTrigger EventName="MouseRightButtonDown">
- <command:EventToCommand PassEventArgsToCommand="True" Command="{Binding GridRightClickCommand}"/>
- </i:EventTrigger>
- </i:Interaction.Triggers>
- <c1:C1FlexGrid.Columns>
- <c1:Column Header="类型" Binding="{Binding OrderTypeStr}"/>
- <c1:Column Header="日期" Binding="{Binding ReviewDate}" Format="yyyy-MM-dd" HorizontalAlignment="Left"/>
- <c1:Column Header="客户代码" Binding="{Binding CustomerCode}"/>
- <c1:Column Header="排单" IsReadOnly="True">
- <c1:Column.CellTemplate>
- <DataTemplate>
- <CheckBox IsChecked="{Binding IsScheduling}"/>
- </DataTemplate>
- </c1:Column.CellTemplate>
- </c1:Column>
- </c1:C1FlexGrid.Columns>
- </c1:C1FlexGrid>
复制代码
如何设置让其只读?
另外,尝试设置CheckBox的IsEnabled="False",虽然可以实现只读效果,但是显示效果差强人意,整个CheckBox灰蒙蒙的看不清,请看下图
如何实现类似C1DataGrid这样的效果? |