カスタム アニメーション イージング関数を作成する BezierSpline エディターを作成しています。ユーザーは、独自のイージング関数を作成するためにベジエ曲線パーツを追加する可能性があります。
DesignerVM を DataContext として共有する 2 つのユーザー コントロール DesignerControl と InfoControl を持つ MainWindow があります。
DesignerControl は、ドラッグ可能な Rectangles を使用してスプラインを表示および編集するためのメイン ビューであり、InfoControl は、ボタンとリストボックスを使用してスプライン パーツを作成、選択、削除し、テキストブロックを使用してコントロール ポイントを編集するためのビューです。
DesignerVM には、SplineVM の ObservableCollection が含まれています。
ObservableCollectionにバインドされた各ユーザーコントロールにリストボックスがあります。
ItemsPanelTemplate を使用してリスト ボックスを designerControl の Canvas に変更しました。今のところ、DataTemplate を ListBox.ItemTemplate として使用して、SplineControl という名前のユーザー コントロールの項目を変更しています。
この SplineControl には、曲線を定義するパスを含む固定サイズのキャンバスと、controlPoint を定義する 4 つの四角形があります。
<UserControl x:Class="Easing_Spline_Tool.SplineControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Easing_Spline_Tool"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
DataContext="SplineVM">
<UserControl.Resources>
<local:MathConverter x:Key="mathconverter"/>
</UserControl.Resources>
<Canvas Width="300" Height="300" x:Name="mycanvas" Background="Black">
<Path x:Name="curve" Stroke="#F02828" StrokeThickness="3">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure>
<PathFigure.Segments>
<PathSegmentCollection x:Name="pathsegment"/>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
<Rectangle Fill="White" x:Name="curvePoint1" Width="8" Height="8" Canvas.Bottom="0" Canvas.Left="0"/>
<Rectangle Fill="White" x:Name="curvePoint2" Width="8" Height="8" RadiusX="4" RadiusY="4" Canvas.Bottom="0" Canvas.Left="{Binding ElementName=mycanvas, Path=ActualWidth, Converter={StaticResource mathconverter}, ConverterParameter=(@VALUE/4)}"/>
<Rectangle Fill="White" x:Name="curvePoint3" Width="8" Height="8" RadiusX="4" RadiusY="4" Canvas.Bottom="0" Canvas.Left="{Binding ElementName=mycanvas, Path=ActualWidth, Converter={StaticResource mathconverter}, ConverterParameter=(@VALUE/2)}"/>
<Rectangle Fill="White" x:Name="curvepoint4" Width="4" Height="4" Canvas.Bottom="0" Canvas.Left="{Binding ElementName=mycanvas, Path=ActualWidth, Converter={StaticResource mathconverter}, ConverterParameter=(@VALUE)}"/>
</Canvas>
</UserControl>
編集: Rectangles のバインドに Rachel Lim の MathConverter を使用していますが、非常にうまく機能します。
アプリケーションを起動すると、ユーザーコントロールがメインウィンドウのキャンバスの左上隅にあり、代わりに左下隅にあるはずです。userControl の垂直方向の配置と水平方向の配置を下と左に設定しました...
また、userControl に Canvas.Bottom と Canvas.Left を設定しようとしましたが、何も変わりませんでした
何か不足していますか?