index > Windows Presentation Foundation ("Avalon") > Rotating a grid

Rotating a grid

Hello

I want to rotate a grid by, for egxample, 45 degrees. How it could be done programically?

Thanks in advance.

Kestutis

you can do something like this(g1 is the name of the grid)

RotateTransform rt = new RotateTransform(45);

g1.RenderTransform = rt;

lee d

To make it rotate 45 degrees around the center you would just do:

myGrid.LayoutTransform = new RotateTransform(45, myGrid.Width / 2, myGrid.Height / 2);

For more details, check out this section of the SDK.

HTH,
Drew




Microsoft C# / WPF MVP
Drew Marsh
Drew Marsh wrote:

myGrid.LayoutTransform = new RotateTransform(45, myGrid.Width / 2, myGrid.Height / 2);

the above will work if Width and Height are specified, if they are not specified, you have to use ActualWidth, ActualHeight

lee d
lee d wrote:
Drew Marsh wrote:

myGrid.LayoutTransform = new RotateTransform(45, myGrid.Width / 2, myGrid.Height / 2);

the above will work if Width and Height are specified, if they are not specified, you have to use ActualWidth, ActualHeight

Yes indeed. Thank you for clarifying that.

Cheers,
Drew




Microsoft C# / WPF MVP
Drew Marsh
reply 5

You can use google to search for other answers

 

More Articles

• Getting a HWND for a Popup
• Singleton with to or more Windows
• 3dmax to sparkle
• Dynamic diagram creation
• Resizable Panel
• Binding to a non string - possible?
• The Name attribute value 'label1' cannot be set on the element 'L...
• How to get reference of treeviewitem?
• Custom EnumConverter not invoked at design-time
• How can I use ResourceDictionary for string resources
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• I am not able to install Orcas Technolog
• Pagination With Xaml(XBAP)
• Bug ? The Enabled control is not effecti
• How to render HTML ?
• What version to report SDK RC1 faults ag
• Issue with WPF Designer in Vista Build 5
• BitmapFrame to stream conversion
• DATA BINDING: Problems attaching a Valid
• load xaml dynamically in to a parent obj
• Changing DataTemplate programmatically
• CheckBox and binding path
• How to get reference to UIElement that h
• loop Media element
• How to access ObjectDataProvider resourc
• Problems with multiple ObjectDataProvide

Hot Articles

• XAML RSS Reader problem
• objectdataprovider.refresh()
• DocumentViewer Style
• Set toolbar-button-style?
• Bind To Method Topic is missing from dow
• Refresh ImageBox
• How to get DependencyProperty by its name?
• SplitButton
• possible 3D rendering problem
• DATA BINDING: Problems attaching a Valid
• Combination bug of TextBox.MaxLength and
• TextRange
• Ivalidate LayoutTransformation
• Event registration fails with No error o
• Making NavigationUI frame specific

Recommend Articles

• Globalization & Localization
• How to remove control box from Window?
• How do I force a template to be instanti
• Canvas.SetLeft not working?
• CompoundFile - Why oh why oh why -
• Need help binding a checkbox to an objec
• A strange Viewport3D-references related
• How to add a column in a Listview dynami
• VS Extensions for WPF
• Help needed Regarding the Grid and ListV
• Terminal Server and WPF
• Windows Vista Explorer-like application
• Animations at GDI speed?
• Where is OpenFileDialog?
• Accesskey on ComboBox?