or
DataTable dt = new DataTable("test");for (int i = 0; i < 10; i++){ dt.Columns.Add("column" + i);}for (int i = 0; i < 10; i++){ var row = dt.NewRow(); for (int j = 0; j < 10; j++) { row[j] = j + i; } dt.Rows.Add(row);}dt.AcceptChanges();Items = dt.AsDataView();
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="253*" />
</Grid.RowDefinitions>
<Button Command="{Binding UndoAllChanges}" Content="Undo all changes" Margin="10" HorizontalAlignment="Left" Padding="5,2" />
<telerik:RadGridView ItemsSource="{Binding Items}" CanUserInsertRows="True" ShowInsertRow="True" Grid.Row="1" />
</Grid>
private ICommand _undoAllChanges;public ICommand UndoAllChanges{ get { if (_undoAllChanges == null) { _undoAllChanges = new DelegateCommand(obj => { Items.Table.RejectChanges(); OnPropertyChanged("Items"); }); } return _undoAllChanges; }}public class LstStyleSelector:StyleSelector
{
public Style Red { get; set; }
public Style Blue { get; set; }
public override Style SelectStyle(object item, DependencyObject container)
{
if (item != null)
{
if (((KeyValuePair<int, string>)item).Key % 2 == 0)
return Red;
else
return Blue;
}
else
return Red;
}
}<Grid>
<Grid.Resources>
<Style x:Key="reditem" TargetType="{x:Type telerik:RadListBoxItem}">
<Setter Property="Background" Value="Red"/>
</Style>
<Style x:Key="bluitem" TargetType="{x:Type telerik:RadListBoxItem}">
<Setter Property="Background" Value="Blue"/>
</Style>
<local:LstStyleSelector x:Key="itemContainerStyle" Blue="{StaticResource bluitem}" Red="{StaticResource reditem}"/>
</Grid.Resources>
<telerik:RadListBox x:Name="lstbx" VerticalAlignment="Center" DisplayMemberPath="Value" ItemContainerStyleSelector="{StaticResource itemContainerStyle}"/>
</Grid>private void Application_Startup(object sender, StartupEventArgs e)
{
//StyleManager.ApplicationTheme = new Windows8TouchTheme(); //StyleSelector not working.
StyleManager.ApplicationTheme = new Office_BlackTheme(); //StyleSelector working fine!
}gridView.ItemsSource = orgList;gridView.SelectedItem = orgList[0];//// gridView.rows[0].Expand(); // <-- Yes, I know this doesn't exist, but pretty please add it.gridView.ItemsSource = orgList;Action a = delegate { gridView.SelectedItem = orgList[0];};Thread.Sleep(100);App.Current.Dispatcher.Invoke(a, null);gridView.RowDetailsVisibilityMode = GridViewRowDetailsVisibilityMode.Visible;gridView.ItemsSource = orgList;Action a = delegate { gridView.SelectedItem = orgList[0]; gridView.UpdateLayout(); var row = gridView.ItemContainerGenerator.ContainerFromItem(gridView.SelectedItem) as GridViewRow; if (row != null) { row.DetailsVisibility = Visibility.Visible; row.IsExpanded = true; }};Thread.Sleep(100);App.Current.Dispatcher.Invoke(a, null);var row2 = row.ChildrenOfType<DetailsPresenter>().FirstOrDefault() as DetailsPresenter;if (row2 != null) { var details = row2.Content as RadGridView; if (details != null) { details.SelectedItem = obj2; details.ScrollIntoView(obj2); }}<telerik:RadChart x:Name="DefectChart" Grid.Row="1" SeriesMappings="{Binding DiagramMappings}"></telerik:RadChart>SeriesMappingCollection _mappings;public SeriesMappingCollection DiagramMappings{ get { if (_mappings == null) { _mappings = new SeriesMappingCollection(); var temp = new SeriesMappingCollection(); var sm = new SeriesMapping(); sm.SeriesDefinition = new StackedBarSeriesDefinition(); sm.ItemMappings.Add(new ItemMapping("Category", DataPointMember.XCategory)); sm.ItemMappings.Add(new ItemMapping("Data", DataPointMember.YValue)); sm.ItemsSource = new List<ChartData>() { new ChartData("C1", 1), new ChartData("C2", 5), new ChartData("C3", 7) }; temp.Add(sm); var sm2 = new SeriesMapping(); sm2.SeriesDefinition = new StackedBarSeriesDefinition(); sm2.ItemMappings.Add(new ItemMapping("Category", DataPointMember.XCategory)); sm2.ItemMappings.Add(new ItemMapping("Data", DataPointMember.YValue)); sm2.ItemsSource = new List<ChartData>() { new ChartData("C1", 10), new ChartData("C2", 7), new ChartData("C3", 18) }; temp.Add(sm2); this._mappings = temp; } return _mappings; } set { _mappings = value; NotifyOfPropertyChange(() => DiagramMappings); }}public class ChartData { public ChartData(string c, double d) { this.Category = c; this.Data = d; } public string Category { get; set; } public double Data { get; set; } }var qRCode = new RadBarcodeQR();qRCode.ErrorCorrectionLevel = QRClassLibrary.Modes.ErrorCorrectionLevel.H;qRCode.Mode = QRClassLibrary.Modes.CodeMode.Byte;qRCode.Version = 2;qRCode.Text = "TestText";const string extension = "png";var dialog = new SaveFileDialog(){ DefaultExt = extension, FileName = "QRBarCode", Filter = "Png (*.png)|*.png"};if (dialog.ShowDialog() == true){ using (var stream = dialog.OpenFile()) { ExportExtensions.ExportToImage(qRCode, stream, new PngBitmapEncoder()); }}