Here is the slightly modified Direct Manipulation Sample app from windows 8 classic samples. I removed all elements except the single Viewport and it's Content (checkered texture). When I set IDirectManipulationVewport::SetViewportRect() with offset to the origin (e.g. SetViewportRect(100, 100, client_rect.right, client_rect.bottom) I expect the content to be aligned at 100, 100. However the content is always aligned at the window (parent IDirectCompositionVisual) origin.
I also tried IDirectManipulationViewport::SetViewportTransform() with translation matrix, but the result is the same.
What is the correct way of positioning the viewport in the visual not at the origin? Is it possible? Or I should create another child IDirectCompositionVisual with viewport, position it with SetOffsetX/Y and add content to it?
Here is a link to documentation
UPD after Rita Han's answer: If you make just the following modifications to the sample:
//modify viewport rectangle in CAppWindow::_SizeDependentChanges()
_viewportOuterRect.left = 100;
_viewportOuterRect.top = 100;
//align content at the center in HRESULT CAppWindow::_InitializeManagerAndViewport()
primaryContentOuter->SetHorizontalAlignment(DIRECTMANIPULATION_HORIZONTALALIGNMENT_CENTER);
primaryContentOuter->SetVerticalAlignment(DIRECTMANIPULATION_VERTICALALIGNMENT_CENTER);
//change zoom boundaries to enable zoom out
hr = primaryContentOuter->SetZoomBoundaries(0.1f, 5.0f);
If you zoom out, you will see the following:
red - actual incorrect viewport rectangle (_viewportOuterRect.left and top coordinates are ignored, however the size is changed).
green - expected viewport rectangle.
blue - expected content aligned position.