わかりました、これはあなたが探しているものではないかもしれませんが、あなたの質問は非常に興味深いものでした.
私はそれを水平に行うことができました (新しい画像は右ではなく左から表示されます)。
ユーザーコントロールで「FlowDirection」を「RightToLeft」に設定すると、必要なことを水平に実行できます。これが垂直に可能かどうかはわかりません。私はまだそれを調べています....
<Canvas FlowDirection="RightToLeft">
<Canvas.Background>
<ImageBrush ImageSource="Resources/image.jpg" Viewport="0,0,32,32" ViewportUnits="Absolute" TileMode="Tile" Stretch="None" AlignmentX="Left" AlignmentY="Bottom" />
</Canvas.Background>
</Canvas>
これは私の UserControl の最初の要素ですが、この「FlowDirection」は、ユーザー コントロールのルートにある基本要素 (通常はグリッド) に配置できます。ただし、キャンバスを使用すると、この「フロー方向」がユーザー コントロール内の他のコンポーネントに影響を与えないことが保証されます。
これがあなたを良い方向に向けてくれることを願っています。
- 編集 -
LOL これが機能するなんて信じられませんが、機能します! 私の最初の作品に基づいて、キャンバスの余白に Converter を使用します。
コンバータ:
[ValueConversion(typeof(double), typeof(Thickness))]
public class SizeToInverseMarginConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (targetType != typeof(Thickness))
throw new InvalidOperationException("The target must be of type 'Thickness'");
double vNewVal = -5000 + (double)value;
return new Thickness(0, vNewVal, 0, 0);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
次に、ユーザー コントロールのコンテンツ:
<UserControl.Resources>
<My:SizeToInverseMarginConverter x:Key="s2m" />
</UserControl.Resources>
<Grid x:Name="MainGrid">
<Canvas FlowDirection="RightToLeft" Margin="{Binding Path=ActualHeight, ElementName=MainGrid, Converter={StaticResource s2m}}">
<Canvas.Background>
<ImageBrush ImageSource="Resources/image.jpg" Viewport="0,0,32,32" ViewportUnits="Absolute" TileMode="Tile" Stretch="None" AlignmentX="Left" AlignmentY="Bottom" />
</Canvas.Background>
</Canvas>
</Grid>