This question is locked. New answers and comments are not allowed.
I want to dynamically change label`s interval in axis.
My chart is located inside dataTemplate, so i can achieve it only using events ChartLoaded and SeriesLoaded.
Is there any chance to achieve it in my viewModel, using binding?
My chart is located inside dataTemplate, so i can achieve it only using events ChartLoaded and SeriesLoaded.
private
void
Series_Loaded(
object
sender, RoutedEventArgs e)
{
var series = (AreaSeries)sender;
var pointsCount = series.DataPoints.Count;
chart.HorizontalAxis.LabelInterval = pointsCount > 10 ? pointsCount / 10 : pointsCount;
}
private
RadCartesianChart chart;
private
void
Chart_Loaded(
object
sender, RoutedEventArgs e)
{
chart = (RadCartesianChart)sender;
}
7 Answers, 1 is accepted
0
Hello Oleg,
The axis' LabelInterval property is a dependency property and I don't see any issue binding it. Looking at your code, I suspect you'll have to use a converter as well.
Regards,
Kiril Stanoev
Telerik
The axis' LabelInterval property is a dependency property and I don't see any issue binding it. Looking at your code, I suspect you'll have to use a converter as well.
Regards,
Kiril Stanoev
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Oleg
Top achievements
Rank 1
answered on 12 Dec 2013, 08:22 AM
Hello Kiril,
Here are details - Argument Exception:
Here is my view:
And vm:
I assign vm in code-behind:
I do not know why i should use converter for this binding.
Here are details - Argument Exception:
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.RuntimePropertyInfo.InternalSetValue(PropertyInfo thisProperty, Object obj, Object value, Object[] index, StackCrawlMark& stackMark)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, XamlPropertyToken inProperty, XamlQualifiedObject& inValue)
at MS.Internal.XcpImports.Application_LoadComponentNative(IntPtr pContext, IntPtr pComponent, UInt32 cUriStringLength, String uriString, UInt32 cXamlStrLength, Byte* pXamlStr, UInt32 cAssemblyStrLength, String assemblyStr)
at MS.Internal.XcpImports.Application_LoadComponent(IManagedPeerBase componentAsDO, String resourceLocator, UnmanagedMemoryStream stream, UInt32 numBytesToRead, String assemblyString)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at PhoneApp1.MainPage.InitializeComponent()
at PhoneApp1.MainPage..ctor()
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type)
at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)
at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
Here is my view:
<telerikChart:RadCartesianChart>
<telerikChart:RadCartesianChart.HorizontalAxis>
<telerikChart:CategoricalAxis />
</telerikChart:RadCartesianChart.HorizontalAxis>
<telerikChart:RadCartesianChart.VerticalAxis>
<telerikChart:LinearAxis LabelInterval=
"{Binding LabelInterval}"
/>
</telerikChart:RadCartesianChart.VerticalAxis>
<telerikChart:AreaSeries ValueBinding=
"Value"
CategoryBinding=
"Category"
CombineMode=
"Stack"
ItemsSource=
"{Binding ChartPoints}"
>
</telerikChart:AreaSeries>
</telerikChart:RadCartesianChart>
And vm:
private
int
_labelInterval = 1;
public
int
LabelInterval
{
get
{
return
_labelInterval; }
set
{
if
(_labelInterval == value)
return
;
_labelInterval = value;
RaisePropertyChanged(
"LabeInterval"
);
}
}
public
MainPage()
{
InitializeComponent();
DataContext =
new
ViewModel();
}
I do not know why i should use converter for this binding.
0
Oleg
Top achievements
Rank 1
answered on 16 Dec 2013, 08:20 AM
Any updates, guys?
0
Hello Oleg,
Please have a look at the attached app. It demonstrates a working example of how to bind the LabelIterval to a view model.
Regards,
Victor
Telerik
Please have a look at the attached app. It demonstrates a working example of how to bind the LabelIterval to a view model.
Regards,
Victor
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Oleg
Top achievements
Rank 1
answered on 17 Dec 2013, 08:34 AM
Thank you, Victor
Unfortunately it still does not work for me, please see attached screen with error.
https://dl.dropboxusercontent.com/u/7530058/error.png
It disappears when i remove binding in xaml.
P.S. i downloaded latest dll`s, run VS2012 Update3,
my solution for WP7, your project for WP8,
i have same problem for both plarforms
Unfortunately it still does not work for me, please see attached screen with error.
https://dl.dropboxusercontent.com/u/7530058/error.png
It disappears when i remove binding in xaml.
P.S. i downloaded latest dll`s, run VS2012 Update3,
my solution for WP7, your project for WP8,
i have same problem for both plarforms
0
Hello Oleg,
Can you please clarify which version of the controls you are using? If you are using an older version the LabelInterval property might not be a dependency property. If you are not using the latest version please try it out and let us know if it still doesn't work.
Regards,
Victor
Telerik
Can you please clarify which version of the controls you are using? If you are using an older version the LabelInterval property might not be a dependency property. If you are not using the latest version please try it out and let us know if it still doesn't work.
Regards,
Victor
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Hi Oleg,
Just to clarify on my part, which is the exact version of your dlls? Also, it would be best if you post a support ticket and attach your app in a zip archive so that I can debug it.
Regards,
Victor
Telerik
Just to clarify on my part, which is the exact version of your dlls? Also, it would be best if you post a support ticket and attach your app in a zip archive so that I can debug it.
Regards,
Victor
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>