Telerik Forums
UI for WPF Forum
1 answer
139 views
Hi Guys, 

Sorry about bringing up a probably n00b question. 
I have a string which is in the format of a csv. I have parsed the csv and want to show the contents in a RadGridView. 
This is what I have done and a bit lost at the moment.

C#
//COnstructor accepting string
        public ucCsvEditor(string csv)
        {
            InitializeComponent();
            using (StringReader sr = new StringReader(csv))
            {
                var reader = new CsvReader(sr);
 
                //CSVReader will now read the whole file into an enumerable
                while (reader.Read())
                {
                    string[] records = reader.CurrentRecord;
                    string[] headers = reader.FieldHeaders;
                    variablesValue.Add(records);
                    variablesHeader.Add(headers);
                }
                //ObservableCollection<string[]> myCollection = new ObservableCollection<string[]>(variablesValue);
                radGridView.ItemsSource = variablesValue;
                //reader.FieldHeaders
            }
        }

XAML:
<Grid>
       <telerik:RadGridView x:Name="radGridView" Grid.Row="0" AutoGenerateColumns="True" IsReadOnly="False" CanUserDeleteRows="False" />
   </Grid>

I call this GridView from the following code:
C#
if (!string.IsNullOrEmpty(csvData))
            {
                RadWindow winCsvEditor = new RadWindow();
                ucCsvEditor temp = new ucCsvEditor(csvData);
                winCsvEditor.Content = temp;
                winCsvEditor.Header = "CSV Editor";
                winCsvEditor.Owner = this;
                winCsvEditor.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                winCsvEditor.CanClose = true;
                winCsvEditor.ShowDialog();
            }
            else
            {
                MessageBox.Show("No Variables available to edit");
            }

The output is shown as shown int he attachment. 

Not exactly the output I was looking for. 
Since the string[] keeps changing each time I call the GridView depending on the parameters. How do I dynamically build the RadGridView. ?? Any helps is appreciated. 
Dimitrina
Telerik team
 answered on 05 Jan 2015
1 answer
114 views
How do I pin/unpin "ALL panes at once" from the "Pin icon" in the top right corner of the pane? I appreciate any help anyone can provide. 
I need to Pin/UnPin all RadPanes when the pin-button is pressed once on any pane. I've been searching the web, forums, and help tickets for a solution. The zipped solution telerik supplies doesn't work correctly and I see mention of a bug regarding loss of state from last April.  I use a toggle button on a radRibbon to handle all panes:

                    <telerik:RadRibbonToggleButton Name="btnToggleInformationPanes" Text="Toggle Pane" LargeImage="/Drill-IT;component/Resources/Icons/WindowList_64.png" Checked="ToogleInformationPanes_Checked" Unchecked="ToogleInformationPanes_Unchecked" IsAutoSize="True" Size="Large">

        private void ToogleInformationPanes_Checked(object sender, RoutedEventArgs e)
        {
            LeftGroupPane.UnpinAllPanes();
        }

        private void ToogleInformationPanes_Unchecked(object sender, RoutedEventArgs e)
        {
            LeftGroupPane.PinAllPanes();
            LeftGroupPane.SelectedIndex = 0;
        }

But I have been unable to duplicate this action in the Selection changed method. This method gets called multiple times, loses track of the state, and only one pane is pinned/unpinned.

        private void LeftGroupPane_SelectionChanged(object sender, RadSelectionChangedEventArgs e)
        {
            if (btnToggleInformationPanes.IsChecked == true)
            {
                ToogleInformationPanes_Checked(sender, e);
            }
            else
            {
                ToogleInformationPanes_Unchecked(sender, e);
            }
        }

How do I pin/unpin ALL panes with one click from the "Pin icon" in the top right corner of the pane?

Thanks for your help! I appreciate it!!!
Vladi
Telerik team
 answered on 05 Jan 2015
2 answers
66 views
We use prism with RadDocking
In the Shell view we have this region :


<telerik:RadSplitContainer InitialPosition="DockedRight" telerik:ProportionalStackPanel.RelativeSize="200, 10">
<telerik:RadPaneGroup prism:RegionManager.RegionName="{x:Static inf:RegionNames.RightSidebarRegion}"/>
</telerik:RadSplitContainer>

When we inject this view  that has IsPinned="False"

<Telerik:RadPane …............….. IsPinned="False">
<Grid>
      <TextBlock Text="some text"/>
</Grid>
</Telerik:RadPane>

We notice that when we navigate to view that have not pane,
the pas injected in the precedent view not removed

IRegion sidebarRegion =  RegionManager.Regions[RegionNames.RightSidebarRegion];
SideBars.ToList().ForEach(sidebarRegion.Remove);

Can you give me a solution for this behavior?


George
Telerik team
 answered on 05 Jan 2015
2 answers
199 views
EDIT: I solved the issue, I just had to create a new background worker for each series.

Hey peeps,

I'm just getting started with Telerik's controls and have successfully managed to plot a multi series chart. Now due to the time it takes to populate the chartdata, I wanted to do this with a background worker. I successfully managed to have a backgroundworker plot a single chartseries, but I don't know how to have it plot multiple. Lets look at the code:


public BackgroundWorker worker = new BackgroundWorker();
 public Window1()
 {
     InitializeComponent();
     InitializeBackgroundWorker();
 }
 
 // Set up the BackgroundWorker object by 
 // attaching event handlers. 
 private void InitializeBackgroundWorker()
 {
     worker.DoWork +=new DoWorkEventHandler(worker_DoWork);
     worker.RunWorkerCompleted +=new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
 }
 
 //Define a New Chart Data Class for each graph
 public class ChartDataClass1
 {
     public double X1 { get; set; }
     public double Y1 { get; set; }
 
     public ChartDataClass1()
     {
 
     }
 }
 
 public class ChartDataClass2
 {
 
     public double X2 { get; set; }
     public double Y2 { get; set; }
 
     public ChartDataClass2()
     {
 
     }
 }
 
 private void btn1_Click(object sender, RoutedEventArgs e)
 {
     worker.RunWorkerAsync();
 }
 
 void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     // On the worker thread...cannot make UI calls from here.
     e.Result = MTLB(worker,e);
 
 
private void worker_RunWorkerCompleted(
     object sender, RunWorkerCompletedEventArgs e)
 {
      
     // First, handle the case where an exception was thrown.
     if (e.Error != null)
     {
         MessageBox.Show(e.Error.Message);
     }
 
     else
     {
         // Finally, handle the case where the operation 
         // succeeded.
         xline.Series[0].ItemsSource = (System.Collections.IEnumerable)e.Result;
     }
 
 }
 
 public System.Collections.Generic.List<ChartDataClass1> MTLB(BackgroundWorker worker, DoWorkEventArgs e)
 {
     int st = 1;
     int sp = 20;
  
     //MATLAB inputs
     MWNumericArray start = 1;
     MWNumericArray stop = 20;
 
     //MATLAB fn
     Reactor.Class1 rxtr_lib = new Reactor.Class1();
     MWArray[] result = rxtr_lib.rxtr(1, start, stop);
     System.Array NH3 = new double[2 * (sp - st + 1)];
     NH3 = ((MWNumericArray)result[0]).ToVector(MWArrayComponent.Real);
 
 
     List<ChartDataClass1> chartData1 = new List<ChartDataClass1>();
     List<ChartDataClass2> chartData2 = new List<ChartDataClass2>();
     for (int i = 0; i < (sp - st); i++)
     {
         ChartDataClass1 cdc = new ChartDataClass1();
         ChartDataClass2 cdc2 = new ChartDataClass2();
         cdc.X1 = i;
         cdc.Y1 = Convert.ToDouble(NH3.GetValue(2 * i));
         cdc2.X2 = i;
         cdc2.Y2 = Convert.ToDouble(NH3.GetValue(2 * i + 1));
 
         chartData1.Add(cdc);
         chartData2.Add(cdc2);
     }
      
     return chartData1;
     
}

The code above populates chartData1 and chartData2, but only allows me to return a single type(chartdataclass1 OR chartdataclass2). My question is, what must I do so that I can return chartData1 AND chartData2 to e.Result? Also, assuming I can return both, how do I then set up e.Result such that I can define Series[0] and Series[1] using e.Result?

Martin Ivanov
Telerik team
 answered on 05 Jan 2015
4 answers
382 views
Hi !

I'm developing  grid excel exporting using ExcelML with UI For WPF Q1 2014 SP1 in WPF Application.

There is a problem that multi line Carriage Returns(\r\n or \n) is not working in a cell  when exporting grid using ExcelML.

SpreadML ( Open Xml at office )

I had searched and found a content. 

This is content that was written in 2009 years.

This content is written that newline characters are not supported in ExcelML format by the Telerik team.

http://www.telerik.com/forums/carriage-returns-when-exporting-grid-using-excelml

Please, What is the solution of  this problem ?


JUNGGON
Top achievements
Rank 1
 answered on 05 Jan 2015
1 answer
234 views

I am using the Office2013 theme.What is the easiest way to change the application font?

I can see that the Windows8 themes have an option for this:

//Windows8 Resources
Windows8Palette.Palette.FontSizeXS = 10;
Windows8Palette.Palette.FontFamily = new FontFamily("Segoe UI");

Dimitrina
Telerik team
 answered on 02 Jan 2015
1 answer
120 views
I am using PRISM/Unity and Telerik's WPF controls to create a business solution for generating and viewing reports.  I have a module that is dedicated to simply displaying the generated reports.  My View for the reports originally was implmented as a <Window> </Window> with a single <ReportViewer> with the report data source bound to a backing field in the ViewModel for the Window.  I am now attempting to convert to a tabbed control structure to allow the users to view more than one report at a time.  I VM defined as a static resource in the window and the codebehind of the window exposes a single method that allows the addition of reports to its tab control (given that it's entirely a piece of display functionality, I don't think it violates the MVVM principles.

Back to the question:  during the add process, I generate an instance report source and add it to an ObserableCollection<InstanceReportSource> that is the ItemSource bound to the "ItemSource" property of the tab control and then show the window that contains the Tab Control. During the AddReport method, I perform a RaisePropertyChanged("ReportSourceCollection") to notify the Tab control that it needs to add a new tab containing a report.  The issue I'm running into is that when the window opens, no report is displayed.  Through my debugging, I've found that the addition of items, and property changed events are properly raised.

Has anyone else had an issue with Report Viewer in the Tab control?

Thanks.
Petar Marchev
Telerik team
 answered on 02 Jan 2015
8 answers
383 views
Hello,

I'm attempting to ILMerge a couple of the control DLLs into another DLL and am having problems where the controls are not able to be loaded at run time. My assumption is that I would need to implement something like what is suggested here for the WinForms controls, but can not find any pre-existing forum discussions or articles on the subject.

Am I missing something, any thoughts/suggestions?

Thanks!
William
Top achievements
Rank 1
 answered on 31 Dec 2014
3 answers
112 views
Hi All, 
I am using WPF RadChart , to create and export charts in code behind, everything is ok in all chart type same as bubble , pie , linear, … but in Bar chart using BarSeriesDefinition, the exported Image has no bar! Labels are shown correctly above hidden bars! Also created chart is shown correctly in WPF RadChart.
in this below code I show the problem
Regards


private void Button_Click(object sender, RoutedEventArgs e)
        {
            ChartBaseParameter ChartParam = new ChartBaseParameter()
            {
                XAxisField = "x",
                YAxisFields = new List<string>() { "y" }
            };
 
            DataTable dt = new DataTable();
            dt.Columns.Add("x", typeof(int));
            dt.Columns.Add("y", typeof(int));
            dt.Rows.Add(1, 1);
            dt.Rows.Add(2, 2);
 
            this.ChartPanel.SeriesMappings.Clear();
            this.ChartPanel.SortDescriptors.Clear();
            this.ChartPanel.ItemsSource = null;
 
            var chart = InitChart(this.ChartPanel, ChartParam, true, dt);
            var fileName = "C:\\myChart.jpg";
            chart.ExportToImage(fileName, new PngBitmapEncoder());
        }
 
    
        public static RadChart InitChart(RadChart chartPanel, ChartBaseParameter chartParam, bool showError, System.Data.DataTable chartTable)
        {
            bool showItemLabels = true;
 
            AnimationManager.IsGlobalAnimationEnabled = false;
            chartPanel.DefaultView.ChartArea.EnableAnimations = false;
 
            chartPanel.BeginInit();
            chartPanel.Width = 300;
            chartPanel.Height = 300;
 
            BarLabelSettings barLabelSetting = new BarLabelSettings();
            barLabelSetting.Distance = 10;
            barLabelSetting.LabelDisplayMode = LabelDisplayMode.Outside;
            barLabelSetting.ShowConnectors = true;
 
            foreach (var YItem in chartParam.YAxisFields)
            {
 
                SeriesMapping seriesmappingi = new SeriesMapping() { LegendLabel = YItem };
                seriesmappingi.SeriesDefinition = new BarSeriesDefinition() { ShowItemLabels = showItemLabels, LabelSettings = barLabelSetting };
                seriesmappingi.ItemMappings.Add(new ItemMapping("y", DataPointMember.YValue) { FieldType = typeof(int) });
                seriesmappingi.ItemMappings.Add(new ItemMapping("x", DataPointMember.XCategory) { FieldType = typeof(int) });
                seriesmappingi.ItemMappings.Add(new ItemMapping("x", DataPointMember.LegendLabel) { FieldType = typeof(int) });
                chartPanel.SeriesMappings.Add(seriesmappingi);
            }
 
            chartPanel.DefaultView.ChartArea.AxisX.LabelRotationAngle = -90;
            chartPanel.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.01;
            chartPanel.DefaultView.ChartArea.AxisX.Title = chartParam.XAxisField;
 
            chartPanel.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
            chartPanel.DefaultView.ChartArea.AxisY.ExtendDirection = AxisExtendDirection.Both;
            chartPanel.DefaultView.ChartArea.LabelFormatBehavior = LabelFormatBehavior.None;
 
            chartPanel.DefaultSeriesDefinition.LegendDisplayMode = LegendDisplayMode.DataPointLabel;
 
            chartPanel.EndInit();
             
            chartPanel.Measure(new Size(1024, 768));
            chartPanel.Arrange(new System.Windows.Rect(new Point(0, 0), chartPanel.DesiredSize));
             
            chartPanel.ItemsSource = chartTable;
            chartPanel.Rebind();
            chartPanel.UpdateLayout();
            return chartPanel;
        }
 
    }
    public class ChartBaseParameter
    {
        public string XAxisField;
        public List<string> YAxisFields;
    }

Petar Marchev
Telerik team
 answered on 31 Dec 2014
3 answers
1.6K+ views
I want to change background color of a particular cell programmatic-ally in wpf telerik radgridview, I have referred  various examples which you have given that using static columns like  (telerik.GridViewDataColumn).

but in my project GridViewDataColumn are not static, it comes dynamically using collections. In this situation how we can handle this? .

please help me as soon as possible . 
Dimitrina
Telerik team
 answered on 31 Dec 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?