SetBounds
недоступно в WPF, но вы можете легко P / вызвать API SetWindowPos
:
private IntPtr _handle;
private void SetBounds(int left, int top, int width, int height)
{
if (_handle == IntPtr.Zero)
_handle = new WindowInteropHelper(this).Handle;
SetWindowPos(_handle, IntPtr.Zero, left, top, width, height, 0);
}
[DllImport("user32")]
static extern bool SetWindowPos(
IntPtr hWnd,
IntPtr hWndInsertAfter,
int x,
int y,
int cx,
int cy,
uint uFlags);
Left
, Top
, Width
и Height
свойства зависимостей будут автоматически обновлены, чтобы отразить новые границы.