Click here to Skip to main content
12,449,748 members (76,975 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# XAML Binding
Hi everybody,
i have following code:
<gauge:CircularTickMarkMajor x:Uid="AlCircularTickMarkMajor1B" TickMarkExtent="4" TickMarkAscent="2" removed="DarkGray" ScalePlacement="Outside" SkipValues= "0,1,2,3,4,5,6,7,8,9,10,11,12,13" x:Name="AlCircularTickMarkMajor1B">
And i want to have something like this:
<gauge:CircularTickMarkMajor x:Uid="AlCircularTickMarkMajor1B" TickMarkExtent="4" TickMarkAscent="2" removed="DarkGray" ScalePlacement="Outside" SkipValues= "{Binding someArray}" x:Name="AlCircularTickMarkMajor1B">
where i set someArray with values dinamically. So i've created a property
private int[] _someArray;
public int[] someArray
{
    get
    {
        return _someArray;
    }
    set
    {   _someArray = value;
        RaisePropertyChanged("someArray");
    }
 }
I have a method that fills this array with values, but it doesn't work. What am I doing wrong?
Thnx
Posted 19-Feb-13 4:31am
Updated 19-Feb-13 4:48am
v3
Comments
richcb 19-Feb-13 10:41am
   
Are you getting any error messages? The code for your property should not even compile as you have an extra curly brace in your set. Also, if you are passing a string in quotes to your method, nothing will happen with it. What datatype does your method accept as an arguement?
AlexanderDymshyts 19-Feb-13 10:58am
   
this extra curly brace just mistake here. i don't get any errors while compiling. My method just generates values of type int for my property someArray on page_Load event. String in quotes just notifying my view that property has changed in my mvvm. I put a breakpoint, and checked that array filled correct, but on my view i don't see it.
richcb 19-Feb-13 11:04am
   
Can you post the method code?
AlexanderDymshyts 19-Feb-13 11:07am
   
public double MaximumScaleValue
{
get { return _maximumScaleValue; }
set
{
_maximumScaleValue = value;
_someArray = new int[Convert.ToInt32(_maximumScaleValue)+1];
for (int i = 0; i <= Convert.ToInt32(_maximumScaleValue); i++)
{
someArray[i] = i;
}
RaisePropertyChanged("MaximumScaleValue");
}
}
source.compiler 19-Feb-13 10:44am
   
cant you set SkipValues attribute programmatically?
AlexanderDymshyts 19-Feb-13 11:07am
   
no, I can't

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Solved with help of DoubleCollection
private DoubleCollection _someArray;
public DoubleCollection SomeArray
{
   get{return _someArray;}
   set{_someArray = value;}
 
public double MaximumScaleValue
{
    get
    {
        return _maximumScaleValue;
    }
    set
    {
        _maximumScaleValue = value;
        RaisePropertyChanged("MaximumScaleValue");
        for (var i = 0; i <= Convert.ToInt32(_maximumScaleValue); i++)
        {
            SomeArray.Add(i);
        }
        RaisePropertyChanged("SomeArray");            }
 }
  Permalink  
v4
Comments
Michael Ochmann 13-May-13 12:06pm
   
Why not Int32Collection?
An ObservableCollection could do it too. This will inform the view if the members of the List has changed. By binding only the Array, it will inform the view that you made an new (empty) Array, but never wenn you fill it.
Alexander Dymshyts 14-May-13 3:16am
   
My fault. It's DoubleCollection because my boss said that the array should be of double values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 14 May 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100