linkprop not working as expected when linking Position of uiimage to Position of uipanel with uiaxes

1 次查看(过去 30 天)
Here's the issue I'm having:
fig=uifigure( ...
'Position',[100,100,300,300]);
img=uiimage(fig, ...
'Position',[51 51 100,100], ...
'ImageSource',zeros(100,100,3));
pan=uipanel(fig);
hLink=linkprop([img,pan],'Position');
This figure behaves as expected when resizing. The image moves but stays the same size, and the panel stays on top of the image. This is the behavior I want.
% After manually resizing the uifigure
>> img.Position
ans =
11 51 100 100
>> pan.Position
ans =
11 51 100 100
However, after adding an axes to the panel, the dominance of the objects with regard to the proplink appears to flip.
ax=uiaxes(pan);
% After manually resizing the uifigure
>> img.Position
ans =
51 51 411 100
>> pan.Position
ans =
51 51 411 100
Instead of the image and panel maintaining a constant size, both begin to be automatically resized by the resizing of the uifigure.
I can create a workaround for my specific case using uifigure callbacks, but I would rather avoid that if possible. Can someone explain what is going on here and what I can do to get the behavior I want?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by