I cannot figure out how to setup SciChartSurface so that it would be initialized right away and IsSizeValidForDrawing returned true.
Now I have the special case for the first call to the view with SciChartSurface and I start working with it after receiving SizeChanged event. In this event handler and afterwards IsSizeValidForDrawing gets true and later on all my requests to the view are OK. It’s quite inconvenient.
When does SciChartSurface get resized? What makes it resize?
Which moment does IsSizeValidForDrawing get true?
What should I do to make the size valid after instantiating or receiving first bunch of data ?
How can I make it progmammatically?
This is my xaml:
…
<s:SciChartSurface.RenderableSeries>
<s:FastLineRenderableSeries XAxisId="XAxis1" YAxisId="YAxis1" AntiAliasing="False" />
<s:FastLineRenderableSeries XAxisId="XAxis2" YAxisId="YAxis2" AntiAliasing="False" />
<s:FastLineRenderableSeries XAxisId="XAxis1" YAxisId="YAxis1" AntiAliasing="False" />
<s:FastLineRenderableSeries XAxisId="XAxis2" YAxisId="YAxis2" AntiAliasing="False" />
<s:FastLineRenderableSeries XAxisId="XAxis1" YAxisId="YAxis1" AntiAliasing="False"/>
<s:FastLineRenderableSeries XAxisId="XAxis2" YAxisId="YAxis2" AntiAliasing="False"/>
</s:SciChartSurface.RenderableSeries>
<s:SciChartSurface.XAxes>
<s:NumericAxis Id="XAxis1" />
<s:NumericAxis Id="XAxis2" />
</s:SciChartSurface.XAxes>
<s:SciChartSurface.YAxes>
<s:NumericAxis Id="YAxis1" />
<s:NumericAxis Id="YAxis2" />
</s:SciChartSurface.YAxes>
</s:SciChartSurface>
<Grid Grid.Row="1" x:Name="myOverviews">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<s:SciChartOverview Grid.Row="0"
XAxisId="XAxis1"
ParentSurface="{Binding ElementName=mySurface}"
DataSeries="{Binding ElementName=mySurface, Path=RenderableSeries[4].DataSeries}"
SelectedRange="{Binding ElementName=mySurface, Path=XAxes[0].VisibleRange, Mode=TwoWay}"
Visibility ="Collapsed"
s:ThemeManager.Theme="BlackSteel">
</s:SciChartOverview>
<s:SciChartOverview Grid.Row="1"
XAxisId="XAxis2"
ParentSurface="{Binding ElementName=mySurface}"
DataSeries="{Binding ElementName=mySurface, Path=RenderableSeries[4].DataSeries}"
SelectedRange="{Binding ElementName=mySurface, Path=XAxes[1].VisibleRange, Mode=TwoWay}"
Visibility ="Collapsed"
s:ThemeManager.Theme="BlackSteel">
</s:SciChartOverview>
</Grid>
All visibilities besides SciChartSurface are “Collapsed”
SciChart version 3.1.0.5077
Thank you
- Anton Kochepasov asked 10 years ago
- last edited 10 years ago
- You must login to post comments
Andrew’s comment helped to understand and solve this problem, which was in instantiating my UserControl dynamically in code behind, without knowing its size. I put the control into XAML, allowing WPF to calculate and set size and problem with RenderSurface, which was unable to draw was gone.
- Anton Kochepasov answered 10 years ago
- You must login to post comments
Without RenderSurfaceBase.IsSizeValidForDrawingset, FastLineRenderableSeries.DataSeries.Append() doesn’t do anything.
I have to take into account this behavior and run the following sequence in my program:
- Create view
- Set new data sources
- (skip this for the first time, dataseries cannot be added as RenderSurfaceBase.IsSizeValidForDrawing == false) Start drawing
- Receive size changed, RenderSurfaceBase.IsSizeValidForDrawing == true, start actual drawing
- Set new data sources
- Start drawing
- Set new data sources
- Start drawing
This workflow is very cumbersome. How can I avoid step 4 and modify step 3?
- Anton Kochepasov answered 10 years ago
- I'm sorry, I have no idea what you're trying to achieve. IsSizeValidForDrawing simply stops scichart from rendering if the size is 0,0. This only occurs if the SciChartSurface has not yet loaded (e.g. it has not yet been displayed in the visual tree). This is normal operation and should not affect DataSeries.Append() in any way. Perhaps you could try to explain the problem a bit more clearly, what you are doing and why, and share a code sample of where you are stuck. We will be happy to help.
- You must login to post comments
I’m trying to achieve SciChartSurface being renderable after instantiating. In my app, I host SciChartSurface in UserControl, which is the part of another UserControl, which is the part of a docking window.
When being instantiating SciChartSurface doesn’t know its own size. Sizes set somewhere down the lifetime of the app and it;s unknown when this size change exactly happens before first render happens. What can I do about this?
- Anton Kochepasov answered 10 years ago
- This is a WPF limitation, nothing to do with SciChart. UserControls do not know their own size until a.) you set the size, or b.) the UserControl has been displayed on the screen. Please see http://stackoverflow.com/a/1695518/303612 for details
- You must login to post comments
RenderSurfaceBase.IsSizeValidForDrawing returns true if ActualWidth and ActualHeight are greater than 0, and are not NaN.
Why do you need this? This flag is used internally inside SciChart to prevent drawing to a bitmap of size 0,0.
- Andrew Burnett-Thompson answered 10 years ago
- You must login to post comments
Please login first to submit.