Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,
i have following code:
C#
<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:
C#
<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
C#
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
Updated 19-Feb-13 4:48am
v3
Comments
Richard C Bishop 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?
Alexander Dymshyts 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.
Richard C Bishop 19-Feb-13 11:04am    
Can you post the method code?
Alexander Dymshyts 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");
}
}
ali_heidari_ 19-Feb-13 10:44am    
cant you set SkipValues attribute programmatically?

1 solution

Solved with help of DoubleCollection
C#
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");            }
 }
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900