Telerik Forums
UI for WPF Forum
1 answer
308 views
After reviewing the documentation, specifically http://www.telerik.com/help/silverlight/radchartview-styles-and-templates-customizing-scatter-points.html, I am exploring ways to scale a custom scatter point based on values of the underlying data.

I know there is an old post in this forum relating to bubble plots in RadChartView (where the bubble is sized based on the underlying data) which is not currently supported.  This was 2012.

 
Looking at the source code for the Candlestick object (as part of the Candlestick series) as a reference, clearly the Candlestick uses sizing (scale) information to determine how big it should be based on the underlying data object.  In particular, it uses the layout and size information in the LayoutSlot to draw itself accordingly which is exactly what I need to do.  So, clearly the Candlestick has the mechanisms to do this internally (and in fact, it would be very nice if the classes were not declared Internal so they could easily be inherited and the issue would be easily solved for me just using a custom Candlestick object to draw what I want.

The scatter point template doesn't seem to get that information (the layout height and width is 0, only the X, Y coordinates are valid).

What I'm trying to do here is to write a custom point template which, using the load event on the template, can get scale information.  I do this in code-behind instead of defining the template in XAML so bear with me.  The template simply is a grid object with a handler attached to its loaded event, which causes the handler to be called whenever the chart renders the custom point template the first time the series is rendered.  In the loaded event of the grid, we simply create content based on the underlying data point.  This is very similar to the concept in the documentation where color and shape is changed.  What I want to do however is SIZE the object based on the underlying data.  Sizing is trivial, however, the sizing should match the current scale of the chart so the dimensions match the axis data, so I need a way to scale the axis information to the pixel.   ChartView does provide a conversion API (http://www.telerik.com/help/silverlight/radchartview-features-conversion.html) but I haven't found a good way to hook that in.  


What I have to date is this:

public static DataTemplate CreatePointTemplate(
         [NotNull]RoutedEventHandler pointLoadedHandler,
         string selectedBooleanField = null,
         string notSelectedBooleanField = null
         )
     {
  
         var template = new DataTemplate();
         var gridFactory = new FrameworkElementFactory(typeof(Grid));
            gridFactory.AddHandler(Control.LoadedEvent, pointLoadedHandler);
            
         template.VisualTree = gridFactory;
  
         return template;
  
     }

The handler code is:

private void HandlePointCreated(object sender, RoutedEventArgs e)
       {
           var grid = (Grid)sender;
           var scatterDataPoint = (ScatterDataPoint)((FrameworkElement)sender).DataContext;
           var data = (HistoricalMarketDataPoint)scatterDataPoint.DataItem;
 
           var layoutSlot = scatterDataPoint.LayoutSlot;
           var bubble = new Ellipse();
           var scale = !Equals(layoutSlot.Height, 0.0) ? data.PriceAverage/layoutSlot.Height : 1.0;
           var scaleSize = new Size(scale*layoutSlot.Width, scale*layoutSlot.Height);
 
           bubble.Width = scaleSize.Width;
           bubble.Height = scaleSize.Height;
            
           var chartPointBrush = new SolidColorBrush(Colors.Red);
           bubble.Fill = chartPointBrush;
           grid.Children.Add(bubble);
 
       }

The layout slot width and height are always 0 for a scatter point so I can't derive the scale from the layout box.   This is not true of the Candlestick object where it uses the layout information to size itself.

My custom point will be rendered at the X and Y locations correctly on the chart, what I'm missing is the ratio of pixel/value for the chart to allow me to compute the scale of the object so it matches the axes.   

For simplicity, I'm using linear axes on both X and Y.

So what I'd like to do is to compute the scale value in the handler code above.   I can easily get a reference to the chart object in the handler if needed, but I have no idea where to fish the plot scale data from right now.

Alternatively, I can use a CandlestickSeries instead of a ScatterSeries and accomplish the same thing but changing the rendering of the candlestick so what I need to make it do.  I haven't found of a way to do that via templates as the relevant overrides are all marked "internal".

Thanks!

E.


EM
Top achievements
Rank 1
 answered on 07 Jun 2013
2 answers
97 views
Not all of the items in SortDescriptors of my GridView are of type  ColumnSortDescriptor . Some are of type SortDescriptor, which has no Column property. It appears that these columns are the ones that  I specified SortingState . Only the columns where I specified sorting through the UI get ColumnSortDescriptor 
I'm trying use Persistence for my grid. How can I tell what column the sort descriptors is for when It is just a SortDescriptor and not a ColumnSortDescriptor?


David
Top achievements
Rank 1
 answered on 07 Jun 2013
3 answers
179 views
How to set the expand direction of the WPF radcontextmenu to UP, so that when I click on expand, the submenuitem popup expands right and upwards.
Rosen Vladimirov
Telerik team
 answered on 07 Jun 2013
0 answers
202 views

Hello,
For instance I have got 5 columns and I am going to show data (price) where each price(column) depends from different Currency.
I should get these currencies and prices from database and show them with correct cultures.
I don't know anything about currencies and prices, there could be anything. So I want to display price correctly for each currency.

I think that each column must have own culture, I should bind this cultures dynamically, and columns need to show prices correctly.

Is it possible?
Could you suggest me anything, best practices, working example, please?

Important: I don't want to have any code-behind and any static data in xaml. I implemented MVVM pattern.
Thank You


Sergiy
Top achievements
Rank 1
 asked on 07 Jun 2013
1 answer
179 views
Hi,

I am creating GridViewComboBoxColumn dynamically in code behind and want to bind ToolTip of the cells in this column to some property as below

var colLabor = new GridViewComboBoxColumn();
var tTemp = new DataTemplate() { DataType = typeof(Labor) };
 
FrameworkElementFactory factoryTextBlock = new FrameworkElementFactory(typeof(TextBox)) { Name = "factoryTextBlock" };
//factoryTextBlock.SetBinding(TextBlock.TextProperty, new Binding("ResourceTypeId"));
factoryTextBlock.SetValue(TextBox.TextProperty, "OK BYE");
factoryTextBlock.SetValue(TextBox.FontSizeProperty, 10.0d);
factoryTextBlock.SetValue(TextBox.WidthProperty, 100.0d);
tTemp.VisualTree = factoryTextBlock;
colLabor.ToolTipTemplate = tTemp;

But couldn't get it working.

But if I do its equivalent (I believe so) in XAML as described here, it works. Unfortunately the column is created on runtime so I can't go with XAML option.

Any ideas/suggestions?

Arpit

Ivan Ivanov
Telerik team
 answered on 07 Jun 2013
1 answer
118 views

Hi telerik support

I have a changing observable list of dates on my viewmodel, and I would like to highlight the days within that collection.

I have tried to implement my own DataTemplateSelector for the dayTemplateselector and I have managed to get the dates from my CollectionViewSource, but it seems that it only works on static data and the changes made to my collection does not appear in the Calendar.

How can I archive binding between the daytemplateSelector and my observableCollection?

Ivo
Telerik team
 answered on 07 Jun 2013
1 answer
109 views
Hi,
In a normal data-binding columns/cells, how can I add a suffix text in superscript? Something like:

abcd <sup>R</sup>

where abcd is from data source and R is an addon superscript.

Thanks!
Ivan Ivanov
Telerik team
 answered on 07 Jun 2013
1 answer
297 views
Hi,

i use a DataForm with lots of DataFormCheckBoxFields. Now i want to Enable or Disable some of these fields if
one of theme is checked?

If this is checked:
<telerik:DataFormCheckBoxField Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" Label="FIRMA:" Foreground="Black" HorizontalAlignment="Left" x:Name="FirmaConf"                                                                           VerticalContentAlignment="Center" VerticalAlignment="Center" DataMemberBinding="{Binding Firma,Mode=TwoWay}"  />

this should be enabled
         <telerik:DataFormCheckBoxField Grid.Row="1" Grid.Column="0" Label="zeigen:" Foreground="Black" HorizontalAlignment="Left" x:Name="FirmazeigenConf"                                                                            VerticalContentAlignment="Center" VerticalAlignment="Center" DataMemberBinding="{Binding FIRzeigen,Mode=TwoWay}"
IsEnabled="{Binding ElementName=FirmaConf, Path=DataMemberBinding, Mode=TwoWay}"/>

But how will i do this?
thanks
Regards
rene

 

Ivan Ivanov
Telerik team
 answered on 07 Jun 2013
1 answer
171 views
Hello,

I'm trying to use use the ContentTemplateSelector propriety inside a RadPane this way :

<selector:CTS x:Key="CTS" DataTemplate1="{StaticResource SomeThing}" DateTemplate2="{StaticResource SomeThing2}"></selector:CTS>
<telerik:RadPane x:Name="FiltersPane" ContentTemplateSelector="{StaticResource CTS}" Content="{Binding Data, Mode=TwoWay}" >

But this don't work. On the other hand, those lines work just fine : 

<DataTemplate x:Key="SomeThing">
            <vw:aView DataContext="{Binding}"></vw:aView>
</DataTemplate>
 
<telerik:RadPane x:Name="FiltersPane" ContentTemplate="{StaticResource SomeThing}" Content="{Binding Data, Mode=TwoWay}">

So, if I use ContentTemplateSelector, it doesn't work. But if I directly set one template with ContentTemplate, it works fine. So, basicaly, all I want to know is if this is the right way to do and the problem come from my code or if it just the way I'm using ContentTemplateSelector that is wrong.

Thank you,
David  
David
Top achievements
Rank 1
 answered on 07 Jun 2013
3 answers
177 views
I am using the following code to render a ScatterLineSeries. The chart renders with points that do not represent real data. Up until 250 inches there is no data with a negative value, which the chart shows. Zooming into the chart, it can clearly be seen to render all values positive.

My data is an array of System.Drawing.Point(double, double), with x values at increments of 0.625 and Y values ranging from -3.5 to 3.5.

        <telerik:RadCartesianChart x:Name="uxChart">
            <telerik:RadCartesianChart.Behaviors>
                <telerik:ChartPanAndZoomBehavior />
            </telerik:RadCartesianChart.Behaviors>
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:LinearAxis x:Name="horizontalAxis"
                                    Minimum="{Binding XAxisMin}"
                                    Maximum="{Binding XAxisMax}"
                                    Title="{Binding XAxisTitle}" />
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis x:Name="verticalAxis"
                                    Minimum="{Binding YAxisMin}"
                                    Maximum="{Binding YAxisMax}"
                                    Title="{Binding YAxisTitle}" />
            </telerik:RadCartesianChart.VerticalAxis>
            <telerik:RadCartesianChart.Series>
                <telerik:ScatterLineSeries ItemsSource="{Binding Data}"
                                           XValueBinding="X"
                                           YValueBinding="Y" />
            </telerik:RadCartesianChart.Series>
            <telerik:RadCartesianChart.Grid>
                <telerik:CartesianChartGrid MajorLinesVisibility="XY" />
            </telerik:RadCartesianChart.Grid>
        </telerik:RadCartesianChart>
Petar Kirov
Telerik team
 answered on 07 Jun 2013
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
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
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
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
VirtualKeyboard
HighlightTextBlock
Security
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?