Telerik Forums
UI for WPF Forum
3 answers
186 views
Hello,

I have an issue where I need some help. I am creating an WPF MVVM application. I have a view with in it displayed a RadGridView. One of the columns of this gridview is a GridViewComboBoxColumn. See code
<telerik:RadGridView x:Name="GridView"  
    ItemsSource="{Binding DataContext.ObservDistributions, ElementName=DistributionView}"  
    AutoGenerateColumns="False"  
    CanUserFreezeColumns="False" 
    acb:CommandBehavior.Event="MouseDoubleClick"  
    acb:CommandBehavior.Command="{Binding SelectCurrentDistributionCommand}" 
    acb:CommandBehavior.CommandParameter="{Binding ElementName=GridView, Path=SelectedItem}"
        <telerik:RadGridView.Columns> 
        <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" IsReadOnly="True" /> 
        <column:DateTimePickerColumn Header="Date" DataMemberBinding="{Binding DateFrom}" Width="200"></column:DateTimePickerColumn> 
        <telerik:GridViewComboBoxColumn Header="Establishment" ItemsSource="{Binding DataContext.Establishments, ElementName=DistributionView}" SelectedValueMemberPath="EstablishmentId" DisplayMemberPath="Name" DataMemberBinding="{Binding Establishment.EstablishmentId, Mode=TwoWay}"
        </telerik:GridViewComboBoxColumn> 
    </telerik:RadGridView.Columns> 
</telerik:RadGridView> 
              
I have in the ViewModel a ObservableCollection named "ObservDistributions". This all works perfectly. The issue is where I change the value of the GridViewComboBoxColumn. I use MouseDoubleClick to send the changes from the View to the ViewModel.  In the acb:CommandBehavior.CommandParameter I sent the item to the ViewModel with a command. This all works but not for the GridViewComboBoxColumn. The changes made to the GridViewComboBoxColumn are not sent to the ViewModel. I think the issue is with the DataMemberBinding in the GridViewComboBoxColumn. I have used the DateTimePickerColumn from Telerik, changes made with this control works fine.

Does anyone have some hint in what direction to look.

Thanx in advance

Stefan
Kareem Azzouny
Top achievements
Rank 1
 answered on 19 Feb 2012
7 answers
454 views
I can insert a comment but when I try to type in the comment I can only type one letter and then the cursor moves back to the document area.
<telerikHTML:HtmlDataProvider Name="dp1" Html="{Binding TaskText, Mode=TwoWay}" RichTextBox="{Binding ElementName=TaskEditor}" />
<telerik:RadRichTextBox x:Name="TaskEditor" Grid.Row="1" Grid.Column="1" Margin="0,5,0,5"
                    AllowDrop="True"  ShowComments="True"
                    IsSelectionMiniToolBarEnabled="false"
                    LayoutMode="Flow"
                    DocumentInheritsDefaultStyleSettings="True"
                    GotFocus="EditorGotFocus" LostFocus="EditorLostFocus"/>
private void EditorGotFocus(object sender, RoutedEventArgs e)
      {
          _lastDataContext = _contextualTabView.DataContext;
          _contextualTabView.DataContext = TaskEditor.Commands;
          _lastTab = _ribbonView.SelectedTab;
          _contextualGroup.IsActive = true;
      }
 
      private void EditorLostFocus(object sender, RoutedEventArgs e)
      {
          _contextualGroup.IsActive = false;
          _lastTab.IsSelected = true;
          _contextualTabView.DataContext = _lastDataContext;
      }

Iva Toteva
Telerik team
 answered on 17 Feb 2012
7 answers
316 views
I'm trying to get the word I just wrote.
I tried these methods.

private void EditorPreviewEditorKeyDown(object sender, PreviewEditorKeyEventArgs e)
{
  var word = radRichTextBox.Document.CaretPosition.GetCurrentWord();
or... var word = radRichTextBox.Document.CaretPosition.GetCurrentSpanBox().Text;.

But none of them gives me the desired result.
Do they work in Wpf? What do they do? How could I get the word 'at the caret'?
Where can I read (wpf)documentation about this?
Ivailo Karamanolev
Telerik team
 answered on 17 Feb 2012
7 answers
206 views
If I have the following column in a radgrid, could someone help me with code behind on how to set the image source programtically based on a column value?

<telerik:GridViewColumn Header="Notes" Width="50">

<telerik:GridViewColumn.CellTemplate>

<DataTemplate>

<telerik:RadButton Name="btnObj" Height="25" Width="25" Click="btnObj_Click">

<telerik:RadButton.Content>

<Image Name="imgNotes" Source="/Images/notes.png" Height="16" Width="16" />

</telerik:RadButton.Content>

 

</telerik:RadButton>

</DataTemplate>

</telerik:GridViewColumn.CellTemplate>

Colin Wright
Top achievements
Rank 2
 answered on 17 Feb 2012
2 answers
157 views
Am I mistaken in understanding that the RadChart control cannot recognize beyond the Day component of a DateTime with regards to specificity. I plotted five values and they all appeared along the origin. Their X-values were different by seconds.
Evgenia
Telerik team
 answered on 17 Feb 2012
1 answer
128 views
I have some logic that will determine what style should be used on a per cell basis. Is there a way to have a style selector for the cells in the scheduler?
Konstantina
Telerik team
 answered on 17 Feb 2012
7 answers
343 views
Hi,

I have a chart (Line) bound to an ObservableCollection containing objects with a DateTime and an int value.
There are a number of problems I ran into with this solution.
So let me first explain the solution (desired result).
The YAxis should display values from 0 to 255 (byte range).
The XAxsi should display a certain number of seconds from the beginning of the data to the end.
To explain it assume 10 seconds of display.
So I check the first datapoint subtract 0.5 seconds (for better display) and set this as XMin.
Then I add 10 seconds and set this as XMax.

While running the programm I add values to the collection and if the latest value is older than the first value + 10 seconds I remove items from the front of the collection.
So what I get is a "growing" display of datapoint - than a "scroll" and again it adds data point....
I have this working - but now my problems (I guess I do something wrong) start.
You can imagine the solution as some kind of "live trend display".

Here the code to setup the chart.
private void InitGrid() {  
    rcData.DefaultView.ChartArea.EnableAnimations = false;  
    rcData.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;  
    rcData.DefaultSeriesDefinition = new LineSeriesDefinition();  
    rcData.DefaultSeriesDefinition.Appearance.Stroke = Brushes.Red;  
    rcData.DefaultSeriesDefinition.Appearance.StrokeThickness = 2;  
    rcData.DefaultSeriesDefinition.ShowItemToolTips = true;  
    rcData.DefaultView.ChartArea.AxisX.IsDateTime = true;  
    rcData.DefaultView.ChartArea.AxisX.LabelRotationAngle = 80;  
    //60 would be better - but then the last label is truncated...  
    rcData.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "HH:mm:ss";  
    rcData.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Normal;  
    rcData.DefaultView.ChartArea.AxisX.AutoRange = false;  
 
    if(m_ocData.Count > 0) {  
        rcData.DefaultView.ChartArea.AxisX.MinValue = m_ocData.First().MeassureTime.AddSeconds(-0.5).ToOADate();  
        rcData.DefaultView.ChartArea.AxisX.MaxValue = m_ocData.First().MeassureTime.AddSeconds(ms_nWindowLength + 1).ToOADate();  
    }  
 
    rcData.DefaultView.ChartArea.AxisX.LabelStep = 1;  
    rcData.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible;  
    rcData.DefaultView.ChartArea.AxisX.Step = 0.000022890946517388029 / 2;  
 
    rcData.DefaultView.ChartArea.AxisY.AutoRange = false;  
    rcData.DefaultView.ChartArea.AxisY.MinValue = 0;  
    rcData.DefaultView.ChartArea.AxisY.MaxValue = 255;  
    rcData.DefaultView.ChartArea.AxisY.MinorTicksVisibility = Visibility.Collapsed;  
 
      
 
    rcData.DefaultView.ChartArea.ItemToolTipOpening += new ItemToolTipEventHandler(ChartArea_ItemToolTipOpening);  
    SeriesMapping seriesMapping = new SeriesMapping();  
    seriesMapping.ItemMappings.Add(new ItemMapping("TheValue", DataPointMember.YValue));  
    seriesMapping.ItemMappings.Add(new ItemMapping("MeassureTime", DataPointMember.XValue));  
    rcData.SeriesMappings.Add(seriesMapping);  
    rcData.ItemsSource = m_ocData;  
    //if done before binding it doesn't work :(  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Clear();  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 0 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 50 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 100 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 150 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 200 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 255 });  
 
}  
 
 
By the way: DataPoints near 0 (0-15) have their label outside the chart - only partial visible

First problem:
When I add the first entry (my collection has one entry) I see a little part of a line - but not no DataPoint (label).

The next problems.
For YAxis I have min==0 max==255 (or 260 if this would help - it doesn't)
I messed around a lot with YAxis settings to have a scale showing 0, 50, 100, 150, 200, 255 (250 or 260 would be OK also).
The Step property doesn't help.
If I set it to 50 I get 51, 102, 153, 205, 255
Setting it to 49, 48 and 47 brings the same result.
With 46 I get 42.5, 85, 127,5.... :)
The only solution I found was to clear the TickPoints and add my values manually.
The problem - the TickPoints are newly created after I bind the data.
I solved this (although I don't understand why it is like this - I said "AutoRange" to off) by clearing / adding the ticks AFTER data binding.

When I reach the end of the space in the chart I do some kind of scroll. This means I remove the first xxx Items till the data fits again.
And because I have "manual XAxis" I change the XMinValue and the XMaxValue to reflect the changes.
The code looks (shoul look) like this:
    if(m_ocData.Count > 0) {  
        rcData.DefaultView.ChartArea.AxisX.MinValue = m_ocData.First().MeassureTime.AddSeconds(-0.5).ToOADate();  
        rcData.DefaultView.ChartArea.AxisX.MaxValue = m_ocData.First().MeassureTime.AddSeconds(ms_nWindowLength+1).ToOADate();  
    }  
 

Here is the next Problem:
AxisX seems to "forget" the setting for Step when I do this.
So I have to set it again!!!

And the next "interesting" thing:
 YAxis also resets it's TickPoints after I do this
So I have to set the values again.
Finally I had to use:
private void ScrollGrid() {  
    if(m_ocData.Count > 0) {  
        rcData.DefaultView.ChartArea.AxisX.MinValue = m_ocData.First().MeassureTime.AddSeconds(-0.5).ToOADate();  
        rcData.DefaultView.ChartArea.AxisX.MaxValue = m_ocData.First().MeassureTime.AddSeconds(ms_nWindowLength+1).ToOADate();  
    }  
    //set some values again - they get lost  
    rcData.DefaultView.ChartArea.AxisX.Step = 0.000022890946517388029 / 2;  
      
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Clear();  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 0 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 50 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 100 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 150 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 200 });  
    rcData.DefaultView.ChartArea.AxisY.TickPoints.Add(new TickPoint() { Value = 255 });  
}  
 

I guess I do something wrong because:
a.) Why should the chart overwrite settings I made when I change a ( totally different) setting
--like with XMinValue and XMaxValue which overrides AxisY.TickPoints
b.) Why should the chart change my TickPoints when I bind data?
--although I told it that I don't want AutoRange
c.) Why is there no easy way to tell the chart "pleas divide my XAxis to seconds"
--OK - would not help here - I need the "free space" to add points (and I found no X-Range property)
--I tried "continuous" scrolling (simply adding a point to the end - and remove on on the front of my collection)
--This flickers so much - unusable :(
d.) Why is "step" for the AxisY divider and not step?
--If Step 50 would (on 0 to 255) would bring 0, 50, 100, 150, 200, 250) would be great (and expected)

My Intention (and the results from what I found):
Have a chart with Y-Labels 0, 50, 100, 150, 200, 250 (or 255)
Has to be done manually - no problem if these values wouldn't been overridden by databind or changing XAxis min / max.
Have an XAxis with a label every second and a display range of 15 seconds (just a number).
Not possible
- I found no way to declare "1 second label distance"
- I found no way to say "XRange 30 seconds"
So I had to do it manually.
But I ran in the problem that AxisX.Step is overwritten when I change the min/max.

I hope someone can tell me what I'm doing wrong.
I have it working - but I guess what I do is "hacking in the dark" :)

Regards

Manfred
Petar Marchev
Telerik team
 answered on 17 Feb 2012
0 answers
116 views
Hi,

is there any example for a dynamic mvvm Model based on a sql-database?

thanks
regards
ww
ITA
Top achievements
Rank 1
 asked on 17 Feb 2012
3 answers
210 views
Hi,

How I can improve the radChart performance when I do a (Window) resizing or zooming ?

I need to show several lineseries with several thousand of points. I'm okay of loading the data to series (it takes around 2-3sec) but after that if I wan't to do windows resizing or zooming, it's lock the UI and takes more than 10sec (if I have 5 series or more loaded to screen) to refresh the screen !!??

I really need to show the actual data so I cannot use the SamplingThreshold - feature

Can I disable redraw or something during the zooming/resizing?

Here's the full code of my demo project.
public partial class MainWindow : Window
{
    private DataTable dt = null;
    public MainWindow()
    {
        InitializeComponent();
        radChart1.DefaultView.ChartArea.EnableAnimations = false;
        radChart1.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;
        //radChart1.SamplingSettings.SamplingFunction = ChartSamplingFunction.Average;
        radChart1.SamplingSettings.SamplingThreshold = 0;
        radChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "HH:mm:ss";
        radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
        radChart1.DefaultView.ChartArea.AxisX.AutoRange = false;
        radChart1.DefaultView.ChartArea.AxisX.IsDateTime = true;
        radChart1.DefaultView.ChartArea.AxisX.MinValue = DateTime.Now.ToOADate();
        radChart1.DefaultView.ChartArea.AxisX.MaxValue = DateTime.Now.AddMinutes(5000).ToOADate();
    }
    private void button2_Click(object sender, RoutedEventArgs e)
    {
        dt = CreateDataTable("SERIES_" + radChart1.SeriesMappings.Count.ToString());
        MessageBox.Show("Data generated for series: " + "SERIES_" + radChart1.SeriesMappings.Count.ToString());
        AddNewSeries("SERIES_" + radChart1.SeriesMappings.Count.ToString());
    }
    private void AddNewSeries(String tag)
    {
        AxisY axisY = new AxisY();
        axisY.AxisName = tag;
        axisY.Title = tag;
        axisY.DefaultLabelFormat = "#VAL{#,##0.00}";
        axisY.AutoRange = false;
        axisY.MinValue = 0;
        axisY.MaxValue = 200;
        axisY.Step = 10;
        Style customAxisYStyle = this.Resources["CustomAxis"] as Style;
        axisY.AxisStyles.AxisLineStyle = customAxisYStyle;
        axisY.AxisStyles.TickLineStyle = this.Resources["AxisYTickStyle"] as Style;
        axisY.AxisStyles.MinorTickLineStyle = this.Resources["AxisYMinorTickStyle"] as Style;
        axisY.AxisStyles.ItemLabelStyle = this.Resources["ItemLabelStyle"] as Style;
        axisY.AxisStyles.TitleStyle = this.Resources["AxisTitleStyle"] as Style;
        if (radChart1.DefaultView.ChartArea.AxisY.AxisName == "")
        {
            radChart1.DefaultView.ChartArea.AxisY = axisY;
        }
        else
        {
            radChart1.DefaultView.ChartArea.AdditionalYAxes.Add(axisY);
            axisY.Visibility = System.Windows.Visibility.Collapsed;
        }
        LineSeriesDefinition seriesDef = new LineSeriesDefinition();
        seriesDef.ShowItemLabels = false;
        seriesDef.ShowPointMarks = false;
        seriesDef.ShowItemToolTips = false;
        seriesDef.SeriesName = tag;
        SeriesMapping m1 = new SeriesMapping();
        m1.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = tag, FieldType = typeof(double) });
        m1.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.XValue, FieldName = tag + "_TS", FieldType = typeof(DateTime) });
        m1.SeriesDefinition = seriesDef;
        m1.LegendLabel = tag;
        m1.SeriesDefinition.AxisName = axisY.AxisName;
        m1.ItemsSource = dt;
        radChart1.SeriesMappings.Add(m1);
    }
    DataTable CreateDataTable(String tagName)
    {
        DataTable dt = new DataTable();
        dt.Columns.Add(new DataColumn(tagName, typeof(Double)));
        dt.Columns.Add(new DataColumn(tagName + "_TS", typeof(DateTime)));
        Random r = new Random(Environment.TickCount);
        for (int i = 0; i < 5000; i++)
        {
            DataRow dr = dt.NewRow();
            if (radChart1.DefaultView.ChartArea.HasItems)
                dr[tagName] = r.Next(1, 100);
            else
                dr[tagName] = r.Next(1, 100);
            dr[tagName + "_TS"] = DateTime.Now.AddMinutes(i);
            dt.Rows.Add(dr);
        }
        return dt;
    }
}


Giuseppe
Telerik team
 answered on 17 Feb 2012
2 answers
85 views
Hi!

To show / hide a pane, I set the IsHidden property to either true or false, this has always worked.

But with the latest release, I get some strange behaviour. If the pane is starting out as hidden (IsHidden = true) when I start the application and the user later changes this through a command (IsHidden = false), the pane is expanded, but without any content (ie the grid inside is not shown).

Am I doing something wrong?
Lennart Bauer
Top achievements
Rank 1
 answered on 17 Feb 2012
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?