This is a migrated thread and some comments may be shown as answers.

TreeMap DataBinding Issues

1 Answer 89 Views
TreeMap and PivotMap
This is a migrated thread and some comments may be shown as answers.
Will Lally
Top achievements
Rank 1
Will Lally asked on 14 Sep 2011, 04:04 PM
Greetings,

First, I am really glad Telerik has added a TreeMap to an already stellar lineup of Silverlight controls.

That said, I'm having an issue with DataBinding a TreeMap using an MVVP type model.  The issue is that I can set data for the TreeMap from the Constuctor of the ViewModel and everything works fine.  However, the control is not updated when setting data from an Async callback (returning data from a web service).  Not even if I crawl the VisualTree, get the object and forcibly set the ItemsSource.

I thought I had everything set up properly but since it isn't working...

View:
<telerik:RadTreeMap x:Name="HeatMap" ItemsSource="{Binding Milestones}" LayoutStrategy="Squarified">
    <telerik:RadTreeMap.TypeDefinitions>
        <telerik:TypeDefinition TargetTypeName="Milestone" ValuePath="Complete" LabelPath="Name" ToolTipPath="Complete" ToolTipFormat="{}{0:P0}">
            <telerik:TypeDefinition.Mappings>
                <telerik:RelativeValueGradientColorizer RangeMinimum="0" RangeMaximum="100">
                    <GradientStop Color="Red" Offset="0"/>
                    <GradientStop Color="Green" Offset="1"/>
                    <GradientStop Color="Yellow" Offset="0.5"/>
                </telerik:RelativeValueGradientColorizer>
            </telerik:TypeDefinition.Mappings>
        </telerik:TypeDefinition>
    </telerik:RadTreeMap.TypeDefinitions>
</telerik:RadTreeMap>

ViewModel:
private List<Milestone> _Milestones;
public List<Milestone> Milestones 
    get
    {
        return this._Milestones;
    }
    set
    {
        if (this._Milestones != value)
        {
            this._Milestones = value;
            this.OnPropertyChanged("Milestones");
        }
    }
}
//Constructor
public FacilityViewModel()
{
    Milestones = new List<Milestone>();
    //Works from the Constructor
    Milestones.Add(new Milestone() { Name = "Mile1", Complete = 10 });
    Milestones.Add(new Milestone() { Name = "Mile2", Complete = 20 });
    Milestones.Add(new Milestone() { Name = "Mile3", Complete = 30 });
    Milestones.Add(new Milestone() { Name = "Mile4", Complete = 40 });
    Milestones.Add(new Milestone() { Name = "Mile5", Complete = 50 });
}
//Async Callback
void GetMilestonePercentComplete(object sender, DataService.GetMilestonePercentCompleteEventArgs e)
{
     //Does not work in the callback
    Milestones.Add(new Milestone() { Name = "Mile6", Complete = 60 });
    Milestones.Add(new Milestone() { Name = "Mile7", Complete = 70 });
    Milestones.Add(new Milestone() { Name = "Mile8", Complete = 80 });
    Milestones.Add(new Milestone() { Name = "Mile9", Complete = 90 });
    Milestones.Add(new Milestone() { Name = "Mile10", Complete = 100 });
        }

1 Answer, 1 is accepted

Sort by
0
Will Lally
Top achievements
Rank 1
answered on 14 Sep 2011, 04:31 PM
My apologies.  Apparently I woke up on the wrong side of stupid this morning.

The issue is with the TreeMap (which is working brilliantly) but with my assignment of the property bound the the control.
The following works correctly.

        //Async Callback
void GetMilestonePercentComplete(object sender, DataService.GetMilestonePercentCompleteEventArgs e)
{
        List<Milestone> _MilestoneList = new List<Milestone>();
    _MilestoneList.Add(new Milestone() { Name = "Mile6", Complete = 60 });
    _MilestoneList.Add(new Milestone() { Name = "Mile7", Complete = 70 });
    _MilestoneList.Add(new Milestone() { Name = "Mile8", Complete = 80 });
    _MilestoneList.Add(new Milestone() { Name = "Mile9", Complete = 90 });
    _MilestoneList.Add(new Milestone() { Name = "Mile10", Complete = 100 });
      
    this.Milestones = _MilestoneList;
        }
Tags
TreeMap and PivotMap
Asked by
Will Lally
Top achievements
Rank 1
Answers by
Will Lally
Top achievements
Rank 1
Share this question
or