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

Strange, too strange. Why ???

2 Answers 50 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yostec
Top achievements
Rank 1
Yostec asked on 20 Aug 2012, 08:46 AM

In   the  behind  code  can't   obtain   the  "Content"     of   Shap   which  is  a  item  of    Diagram control.

This    is   a   serious   problem  ,   indicating   that   the   "  not   will  object    reference    set    to     an    instance   of     an object.   "    error.

XAML:
       <telerik:RadDiagramShape Geometry="{telerik:CommonShape ShapeType=RoundedRectangleShape}" 
             x:Name="rd_SiPing" Width="100" Height="35"
             Content="Harvard University"
             Tag="A"
             FontSize="14"
             Position="193,120"
             Background="LightGray"                      
             MouseLeftButtonDown="rd_SiPing_MouseLeftButtonDown" >
                            
            </telerik:RadDiagramShape>


             <telerik:RadDiagramShape Geometry="{telerik:CommonShape ShapeType=RoundedRectangleShape}" 
             x:Name="rd_SiPingValue" Width="100" Height="25"
             Content="1716.0kW"
             Tag="A"
             FontSize="12"
             Position="193,160"
             Background="LightGray"    
            />


Code  behind:
        private void rd_SiPing_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            string str = rd_SiPingValue.Content.ToString();
            string strtwo = rd_Region.Content.ToString();
            string strthree = rd_SiPing.Tag.ToString();

          Question:   Three   lines   of   code   as   above    are   all   prompt     error:   "not   will  object    reference    set    to     an    instance   of     an object."
            Why???    

        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Alex Fidanov
Telerik team
answered on 22 Aug 2012, 07:28 AM
Hello,

 This is because Silverlight cannot resolve correctly the names of the nested controls that are declared in xaml - the names of the shapes inside the RadDiagram. Although, the diagram looks and behaves like an ItemsControl, it truly is not one - it just mimics it. If it were, then these names would be resolved correctly.

Your best option is to use the Shapes or Items collections of the diagram to get the shape references in the code behind.

Kind regards,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Yostec
Top achievements
Rank 1
answered on 27 Aug 2012, 08:42 AM
Thanks  a  lot...

Tags
Diagram
Asked by
Yostec
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Yostec
Top achievements
Rank 1
Share this question
or