在我的ModelView中,我有一个BitmapImages的ObservableCollection,它显示在我的视图的列表框中。我正在尝试旋转ObservableCollection中选定的图像。
发布于 2011-07-07 22:03:58
好了,弄清楚了,如果有什么看起来很愚蠢的事情,你可以让我知道
//Create a transform
TransformedBitmap tBmp = new TransformedBitmap();
tBmp.BeginInit();
//Set the source = to the image currently selected
tBmp.Source = _Scans[_selectedImage].MyImage;
RotateTransform rt = new RotateTransform(180);
tBmp.Transform = rt;
tBmp.EndInit();
//Create a new source after the transform
BitmapSource s1 = tBmp;
BitmapImage bi = BitmapSourceToBitmapImage(s1);
//Add create the item and replace the current item in the collection
//edited according to comment
//ScannedImages s = new ScannedImages();
//s.MyImage = bi;
//_Scans[_selectedImage] = s;
Scans[_selectedImage].MyImage = BitmapSourceToBitmapImage(s1);发布于 2011-07-07 00:40:34
在定义图像显示方式(作为ListBox项)的DateTemplate中,可以使用.RenderTransform属性来转换/旋转控件。
Button示例:
<Button
<Button.RenderTransform>
<RotateTransform CenterX="0" CenterY="0" Angle="45"/>
</Button.RenderTransform>
Test</Button>Have a read more on How to Rotate an object? MSDN Article
https://stackoverflow.com/questions/6599453
复制相似问题