<telerik:RadCartesianChart x:Name="chart" Grid.Column="0"> <telerik:RadCartesianChart.Series> <telerik:BarSeries ItemsSource="{Binding DataItems}" ValueBinding="Value" CategoryBinding="DayPeriod" > <telerik:BarSeries.PointTemplate> <DataTemplate> <Rectangle Fill="{Binding Converter={StaticResource BrushConverter}, ConverterParameter={StaticResource brushes}}"/> </DataTemplate> </telerik:BarSeries.PointTemplate> </telerik:BarSeries> </telerik:RadCartesianChart.Series> <telerik:RadCartesianChart.VerticalAxis> <telerik:LinearAxis Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" MajorStep="{Binding StepSize}" LabelStyle="{StaticResource axisLabelStyle}" /> </telerik:RadCartesianChart.VerticalAxis> <telerik:RadCartesianChart.HorizontalAxis> <telerik:CategoricalAxis LabelFitMode="Rotate" LabelInterval="2"/> </telerik:RadCartesianChart.HorizontalAxis></telerik:RadCartesianChart><telerik:RadGridView Name="GridViewMyGrid" ItemsSource="{Binding MyCollection}" AutoGenerateColumns="False" IsReadOnly="True" CanUserFreezeColumns="False" GroupRenderMode="Flat" ShowColumnFooters="True" ShowGroupFooters="True" AutoExpandGroups="True" IsFilteringAllowed="False" ShowGroupPanel="False" FrozenColumnCount="2" SelectionMode="Extended" ><telerik:RadGridView.ColumnGroups> <telerik:GridViewColumnGroup Name="Group1ColumnGroup" Header="Group1"> <telerik:GridViewColumnGroup.HeaderTemplate> <DataTemplate> <TextBlock Text="Group1" TextAlignment="Center" FontWeight="Bold"></TextBlock> </DataTemplate> </telerik:GridViewColumnGroup.HeaderTemplate> </telerik:GridViewColumnGroup><telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding GroupName}" ShowColumnWhenGrouped="False" /> <telerik:GridViewDataColumn Header="Item1" DataMemberBinding="{Binding Item1}"> <telerik:GridViewDataColumn.AggregateFunctions> <telerik:FirstFunction/> </telerik:GridViewDataColumn.AggregateFunctions> <telerik:GridViewDataColumn.GroupFooterTemplate> <DataTemplate> <TextBlock FontWeight="Bold"> <Run Text="Subtotal "/> <Run Text="{Binding Value.GroupName}"/> </TextBlock> </DataTemplate> </telerik:GridViewDataColumn.GroupFooterTemplate> <telerik:GridViewColumn.Footer> <TextBlock FontWeight="Bold"> <Run Text="Asset Total"/> </TextBlock> </telerik:GridViewColumn.Footer> </telerik:GridViewDataColumn>
private void ButtonExportStrats_OnClick(object sender, RoutedEventArgs e) { var grid = GridViewMyGrid; var dialog = new SaveFileDialog(); dialog.DefaultExt = "*.xlsx"; dialog.Filter = "Excel Workbook (*.xlsx)|*.xlsx"; if (dialog.ShowDialog() == true) { Workbook book = null; using (var stream = new MemoryStream()) { grid.Export(stream, new GridViewExportOptions() { Format = ExportFormat.Csv, ShowColumnFooters = grid.ShowColumnFooters, ShowColumnHeaders = grid.ShowColumnHeaders, ShowGroupFooters = grid.ShowGroupFooters }); stream.Position = 0; book = new CsvFormatProvider().Import(stream); if (book != null) { var provider = new XlsxFormatProvider(); using (var output = dialog.OpenFile()) { provider.Export(book, output); } } } } }I have a RadGridView which contains GridViewComboBoxColumn as column.
Let consider RadGridView having ItemsSource as ObservableCollection<Product> and GridViewComboBoxColumn ItemsSource is List.
I want to set the GridViewComboBoxColumn SelectedItem property based on property in RadGridView ItemsSource i.e based on ProductTypeId in item/row/Product of ItemsSource/ObservableCollection<Product>.
However Product class has property ProductTypeId of type int and not ProductType object as property.
So how can I set GridViewComboBoxColumn SelectedItem so that it display value of Product.ProductTypeId as selected. And also I want to bind SeletedItem with Mode = TwoWay so that whenever ComboBox SelectedItem changes it will be reflected in RadGridView
's ItemsSource.
One more thing the ProductId name is different in Product (Bound to RadGridView) class as well as ProductType class. However I can change this to be the same. Current it's like ProductType.Id and Product.TypeId.
Any help would be much appreciated.
Thanks.