DevExpress中自定义CellTemplate数据绑定不显示的问题
2014-03-12 00:01
453 查看
定义Student类,其中有布尔值属性IsNormal和IsLate,View中使用DevExpress的GridControl,将两个布尔值放入一个单元格中,以RadioButton显示,需要自定义CellTemplate,但是当进行RadioButton的Checked属性和两个布尔值进行绑定的时候总是出错,原来是数据并没有绑过去,正确的绑定方式应该是,注意
Binding RowData.Row.IsNormal
<dxg:GridControl Name="datagrid" AutoGenerateColumns="None" ShowBorder="False" CurrentItem="{Binding CurrentItem,Mode=TwoWay}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" ItemsSource="{Binding Students}"> <dxg:GridControl.View> <dxg:TableView AutoWidth="True" AllowEditing="True"/> </dxg:GridControl.View> <dxg:GridControl.Columns> <dxg:GridColumn Header="学号" Binding="{Binding Sid,Mode=TwoWay}"/> <dxg:GridColumn Header="姓名" Binding="{Binding Sname,Mode=TwoWay}"/> <dxg:GridColumn Header="性别" Binding="{Binding Sgender,Mode=TwoWay}"/> <dxg:GridColumn Header="班级" Binding="{Binding Sclass,Mode=TwoWay}"/> <dxg:GridColumn Header="状态"> <dxg:GridColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=dockPanel,Path=DataContext.BeforeItemsVisibility,Mode=TwoWay}"> <RadioButton Content="出勤" IsChecked="{Binding RowData.Row.IsNormal,Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <i:InvokeCommandAction Command="{Binding ElementName=dockPanel,Path=DataContext.NormalCommand}" CommandParameter="{Binding ElementName=datagrid}"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> <RadioButton Content="迟到" IsChecked="{Binding RowData.Row.IsLate,Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <i:InvokeCommandAction Command="{Binding ElementName=dockPanel,Path=DataContext.LateCommand}" CommandParameter="{Binding ElementName=datagrid}"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> <RadioButton Content="请假" IsChecked="{Binding RowData.Row.IsReasonable,Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <i:InvokeCommandAction Command="{Binding ElementName=dockPanel,Path=DataContext.ReasonableCommand}" CommandParameter="{Binding ElementName=datagrid}"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> <RadioButton Content="旷课" IsChecked="{Binding RowData.Row.IsAbsent,Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <i:InvokeCommandAction Command="{Binding ElementName=dockPanel,Path=DataContext.AbsentCommand}" CommandParameter="{Binding ElementName=datagrid}"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> </StackPanel> <StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=dockPanel,Path=DataContext.AfterItemsVisibility,Mode=TwoWay}"> <RadioButton Content="早退" IsChecked="{Binding RowData.Row.IsLeaved,Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <i:InvokeCommandAction Command="{Binding ElementName=dockPanel,Path=DataContext.LeavedCommand}" CommandParameter="{Binding ElementName=datagrid}"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> <RadioButton Content="正常" IsChecked="{Binding RowData.Row.IsRight,Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <i:InvokeCommandAction Command="{Binding ElementName=dockPanel,Path=DataContext.RightCommand}" CommandParameter="{Binding ElementName=datagrid}"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> </StackPanel> </StackPanel> </DataTemplate> </dxg:GridColumn.CellTemplate> </dxg:GridColumn> </dxg:GridControl.Columns> </dxg:GridControl>参考网址https://www.devexpress.com/Support/Center/Question/Details/Q341304
相关文章推荐
- ioni3 http请求数据绑定时数组嵌套的显示问题
- JavaFx中TableView 的列中的数据进行自定义显示的问题
- ioni3 http请求数据绑定时数组嵌套的显示问题
- tableview 自定义cell 不显示 self 与 sel.contentview 的区别 多选右移cell不移动的问题
- C#数据绑定中,时间为空时显示时间为原始日期问题
- RadioButton绑定数据与显示问题,类似数据字典问题,如男女Code。
- iOS tableViewCell 在自定义高度方法中遇到的问题,cell高度为0,cell显示不出来,cell直接显示第几个而不是...cell显示个数不对
- Excel 过滤选择数据后,某个Cell显示其值,并自定义合计的VBA.
- 解决自定义cell分割线在iPhone4中不显示的问题
- Flex中自定义组件ItemRenderer,数据绑定dataprovider,刷新问题。
- Android布局设计之ExpandableList绑定XML数据构成级联、item布局页面的控件查找及配置child事件,自定义适配显示内容
- 获取DataGridView绑定BindingSource的数据表,并根据树控件点击进行筛选数据表,下拉控件自定义排序问题初步解决方法,解决了该行属于另一个表的错误提示.
- datagrid绑定list没有数据 表头不显示的问题
- 复杂自定义数据对象绑定到GridView的问题
- 有关绑定没有数据显示的问题
- 对gridview绑定数据的操作方法及自定义显示内容
- 解决UITableView数据没有充满屏幕时,显示多余的空白cell的问题
- 使用数据绑定和 WPF 自定义数据显示
- 对gridview绑定数据的操作方法及自定义显示内容
- [转载] 使用IValueConverter接口实现自定义绑定数据的显示方式