我正在尝试使用我在此网站上找到的调整大小广告: https://denisvuyka.wordpress.com/2007/10/15/wpf-simple-adorner-usage-with-drag-and-resize-operations/
我像这样调整了我的xaml
<Grid Background="Transparent"
x:Name="border">
<Viewbox Stretch="Fill"
StretchDirection="Both">
<ContentControl>
<sourceView:CommentView x:Name="_sourceElementView" />
</ContentControl>
</Viewbox>
<TextBox Width="Auto"
Height="Auto"
Margin="15,10,15,40"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="Top"
AcceptsReturn="True"
Background="#33FFFFFF"
BorderThickness="0"
FontSize="12"
Text="{Binding Path=PetriElement.Comment,
UpdateSourceTrigger=PropertyChanged,
Mode=TwoWay}"
TextWrapping="Wrap" />
</Grid>
我的codebheind看起来像教程的建议。 Grid
是装饰者的界面。 (将myCanvas
替换为教程中的border
。
右上拇指和右下拇指工作正常,但左上和左下拇指将调整宽度和高度,但不会调整控件的位置。 (左上角是固定的)
问题可能是,adorner文件中的这行代码始终返回Nan
:
double left_old = Canvas.GetLeft(adornedElement);
但我不知道如何获得该位置,我也不知道这是否是唯一的问题。
感谢您的帮助