Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Cannot set a property on object 'Identity' because it is in a read-only state. [modified]

Cannot set a property on object 'Identity' because it is in a read-only state. [modified]

Scheduled Pinned Locked Moved WPF
helpcsharpwpfdebugging
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ASysSolvers
    wrote on last edited by
    #1

    I am getting a eroor from my code, i cant trace the issue/bug . here is my code bit... private void DoArrange() { Point center = new Point((this.Width - ItemSize) / 2, (this.Height - ItemSize) / 2); double radiusX = center.X; double radiusY = center.Y; double scale = ScalePerspective; for (int i = 0; i < Children.Count; i++) { UIElement item = Children[i]; double radians = (double)item.GetValue(CarouselPanel.AngleProperty); Point p = new Point( (Math.Cos(radians) * radiusX) + center.X, (Math.Sin(radians) * radiusY) + center.Y ); if (item.RenderTransform == null) { item.RenderTransform = new MatrixTransform(); item.RenderTransformOrigin = new Point(0.5, 0.5); } MatrixTransform mt = item.RenderTransform as MatrixTransform; double scaleMinusRounding = p.Y / (center.Y + radiusY); double scaleX = Math.Min(scaleMinusRounding + scale, 1.0); double scaleY = Math.Min(scaleMinusRounding + scale, 1.0); Matrix mx = new Matrix(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0); _**mt.Matrix = mx;**_ item.RenderTransform = mt; int zIndex = (int)((p.Y / base.Height) * 50); item.SetValue(Canvas.ZIndexProperty, zIndex); Rect r = new Rect(p.X, p.Y, ItemSize, ItemSize); item.Arrange(r); } } What could be the issue i am using a WPF(win) application.

    modified on Thursday, July 9, 2009 9:48 AM

    P 2 Replies Last reply
    0
    • A ASysSolvers

      I am getting a eroor from my code, i cant trace the issue/bug . here is my code bit... private void DoArrange() { Point center = new Point((this.Width - ItemSize) / 2, (this.Height - ItemSize) / 2); double radiusX = center.X; double radiusY = center.Y; double scale = ScalePerspective; for (int i = 0; i < Children.Count; i++) { UIElement item = Children[i]; double radians = (double)item.GetValue(CarouselPanel.AngleProperty); Point p = new Point( (Math.Cos(radians) * radiusX) + center.X, (Math.Sin(radians) * radiusY) + center.Y ); if (item.RenderTransform == null) { item.RenderTransform = new MatrixTransform(); item.RenderTransformOrigin = new Point(0.5, 0.5); } MatrixTransform mt = item.RenderTransform as MatrixTransform; double scaleMinusRounding = p.Y / (center.Y + radiusY); double scaleX = Math.Min(scaleMinusRounding + scale, 1.0); double scaleY = Math.Min(scaleMinusRounding + scale, 1.0); Matrix mx = new Matrix(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0); _**mt.Matrix = mx;**_ item.RenderTransform = mt; int zIndex = (int)((p.Y / base.Height) * 50); item.SetValue(Canvas.ZIndexProperty, zIndex); Rect r = new Rect(p.X, p.Y, ItemSize, ItemSize); item.Arrange(r); } } What could be the issue i am using a WPF(win) application.

      modified on Thursday, July 9, 2009 9:48 AM

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      I can't see the Identity property in your code. Are you sure this is where the problem is?

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

      My blog | My articles | MoXAML PowerToys | Onyx

      A 1 Reply Last reply
      0
      • P Pete OHanlon

        I can't see the Identity property in your code. Are you sure this is where the problem is?

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        A Offline
        A Offline
        ASysSolvers
        wrote on last edited by
        #3

        I edidted the post again,..the error raised from the underlined statement..

        1 Reply Last reply
        0
        • A ASysSolvers

          I am getting a eroor from my code, i cant trace the issue/bug . here is my code bit... private void DoArrange() { Point center = new Point((this.Width - ItemSize) / 2, (this.Height - ItemSize) / 2); double radiusX = center.X; double radiusY = center.Y; double scale = ScalePerspective; for (int i = 0; i < Children.Count; i++) { UIElement item = Children[i]; double radians = (double)item.GetValue(CarouselPanel.AngleProperty); Point p = new Point( (Math.Cos(radians) * radiusX) + center.X, (Math.Sin(radians) * radiusY) + center.Y ); if (item.RenderTransform == null) { item.RenderTransform = new MatrixTransform(); item.RenderTransformOrigin = new Point(0.5, 0.5); } MatrixTransform mt = item.RenderTransform as MatrixTransform; double scaleMinusRounding = p.Y / (center.Y + radiusY); double scaleX = Math.Min(scaleMinusRounding + scale, 1.0); double scaleY = Math.Min(scaleMinusRounding + scale, 1.0); Matrix mx = new Matrix(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0); _**mt.Matrix = mx;**_ item.RenderTransform = mt; int zIndex = (int)((p.Y / base.Height) * 50); item.SetValue(Canvas.ZIndexProperty, zIndex); Rect r = new Rect(p.X, p.Y, ItemSize, ItemSize); item.Arrange(r); } } What could be the issue i am using a WPF(win) application.

          modified on Thursday, July 9, 2009 9:48 AM

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Basically, you have a frozen object here (you can tell this by checking mt.Matrix.IsFrozen). Once an object is frozen, you can't modify it - instead, you have to clone it and work with that.

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

          My blog | My articles | MoXAML PowerToys | Onyx

          A 1 Reply Last reply
          0
          • P Pete OHanlon

            Basically, you have a frozen object here (you can tell this by checking mt.Matrix.IsFrozen). Once an object is frozen, you can't modify it - instead, you have to clone it and work with that.

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

            My blog | My articles | MoXAML PowerToys | Onyx

            A Offline
            A Offline
            ASysSolvers
            wrote on last edited by
            #5

            Pete O'Hanlon wrote:

            (you can tell this by checking mt.Matrix.IsFrozen).

            i cannot find any handle like that, but i found something mt.Matrix.IsIdentity which is returns a bool value. What it does?.. Your corperation is really appreciated!

            P 1 Reply Last reply
            0
            • A ASysSolvers

              Pete O'Hanlon wrote:

              (you can tell this by checking mt.Matrix.IsFrozen).

              i cannot find any handle like that, but i found something mt.Matrix.IsIdentity which is returns a bool value. What it does?.. Your corperation is really appreciated!

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              ASysSolvers wrote:

              i cannot find any handle like that, but i found something mt.Matrix.IsIdentity which is returns a bool value. What it does?..

              This property identifies whether or not a matrix is the identity matrix. Basically, an identity matrix is a square matrix which has 1s on the main diagonal and 0s elsewhere.

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

              My blog | My articles | MoXAML PowerToys | Onyx

              A 1 Reply Last reply
              0
              • P Pete OHanlon

                ASysSolvers wrote:

                i cannot find any handle like that, but i found something mt.Matrix.IsIdentity which is returns a bool value. What it does?..

                This property identifies whether or not a matrix is the identity matrix. Basically, an identity matrix is a square matrix which has 1s on the main diagonal and 0s elsewhere.

                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                My blog | My articles | MoXAML PowerToys | Onyx

                A Offline
                A Offline
                ASysSolvers
                wrote on last edited by
                #7

                Do you have any idea to modify my code in the correct way?.. im struggled now.. i dont knw,.. i want to use this in WPF(Windows) application,..but fine in web it works,.. In windows it gives runtine error like in Thread subject..

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups