바인딩을 통해 사각형의 회전을 제어하는 방법이 있습니까? 나는이 방법을 시도했지만 어떤 생각이 들지 않습니까?AngleProperty에 이중 속성 바인딩
// class Unit
private double _rotation;
public double rotation
{
get
{
return _rotation;
}
set
{
_rotation = value;
OnPropertyChanged("rotation");
}
}
public Binding rotationBinding { get; set; }
// Controller class generating UI
private Rectangle GenerateUnit(Unit u)
{
Rectangle c = new Rectangle() { Width = u.size, Height = u.size };
c.Fill = new ImageBrush(new BitmapImage(new Uri(@"..\..\Images\tank\up.png", UriKind.Relative)));
c.SetBinding(Canvas.LeftProperty, u.xBinding);
c.SetBinding(Canvas.TopProperty, u.yBinding);
RotateTransform rt = new RotateTransform();
BindingOperations.SetBinding(rt, RotateTransform.AngleProperty, u.rotationBinding);
c.LayoutTransform = rt;
return c;
}
X 및 Y 바인딩이 제대로 작동하므로 올바르게 구현 된 것 같습니다.
각도 속성을 바인딩하는 방법을 찾고 있습니다. 회전 속성을 변경하면 UI에서 사각형이 회전합니다. 애니메이션이 필요 없으며, 각도를 즉시 바꿀 수 있습니다.
감사
어떻게 'rotationBinding'을 만드나요? 그 코드도 게시해야합니다. – Clemens
예. 잘못 쓰여졌습니다 ... 쓸모없는 쓰레드가 유감입니다. – Safiron