回复 7楼xuanyuan的帖子
回复 7楼xuanyuan的帖子
如果ComboBox的数据是动态的,可以使用下面的方法来实现
XAML:
- <c1:C1FlexGrid Name="_flex" Grid.Row="1" AutoGenerateColumns="False">
- <c1:C1FlexGrid.Columns>
- <!-- add some bound columns as usual -->
- <c1:Column Header="Line" Binding="{Binding Line, Mode=TwoWay}" />
- <c1:Column Header="Name" Binding="{Binding Name, Mode=TwoWay}" />
- <c1:Column Header="Color" Binding="{Binding Color, Mode=TwoWay}" />
- <c1:Column Header="Price" Binding="{Binding Price, StringFormat=c, Mode=TwoWay}" HorizontalAlignment="Right" />
- <c1:Column Header="Rating" Binding="{Binding Rating, Mode=TwoWay}"/>
- </c1:C1FlexGrid.Columns>
- </c1:C1FlexGrid>
复制代码
MainPage.xaml.cs:
- public partial class MainPage : UserControl
- {
- // data source
- System.ComponentModel.ICollectionView _view = Product.GetProducts(200);
- public MainPage()
- {
- InitializeComponent();
-
- // bind the grid to the data
- _flex.ItemsSource = _view;
- _flex.PrepareCellForEdit += new EventHandler<CellEditEventArgs>(_flex_PrepareCellForEdit);
- }
- void _flex_PrepareCellForEdit(object sender, CellEditEventArgs e)
- {
- if (_flex.Columns[e.Column].BoundPropertyName == "Rating")
- {
- var combo = (e.Editor as Border).Child as C1FlexComboBox;
- combo.DropDownItems = new int[] { 0, 1, 2, 3, 4, 5, 6 };
- }
- }
- }
复制代码 |