Strange, too strange. Why ???

3 posts, 1 answers
  1. Yostec
    Yostec avatar
    19 posts
    Member since:
    Aug 2012

    Posted 20 Aug 2012 Link to this post

    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.

           <telerik:RadDiagramShape Geometry="{telerik:CommonShape ShapeType=RoundedRectangleShape}" 
                 x:Name="rd_SiPing" Width="100" Height="35"
                 Content="Harvard University"
                 MouseLeftButtonDown="rd_SiPing_MouseLeftButtonDown" >

                 <telerik:RadDiagramShape Geometry="{telerik:CommonShape ShapeType=RoundedRectangleShape}" 
                 x:Name="rd_SiPingValue" Width="100" Height="25"

    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."

  2. Answer
    Alex Fidanov
    Alex Fidanov avatar
    636 posts

    Posted 22 Aug 2012 Link to this post


     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.

  3. DevCraft R3 2016 release webinar banner
  4. Yostec
    Yostec avatar
    19 posts
    Member since:
    Aug 2012

    Posted 27 Aug 2012 Link to this post

    Thanks  a  lot...

Back to Top