Cannot set a property on object 'Identity' because it is in a read-only state. [modified]
-
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
-
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
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.
-
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.
I edidted the post again,..the error raised from the underlined statement..
-
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
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.
-
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.
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!
-
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!
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.
-
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.
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..