ThumbコントロールのDragDeltaを使用してドラッグできるカスタムコントロールを作成しました。私は、カスタムコントロールContentPresenter内に図形、画像またはテキストブロックを挿入できるようにしたい。カスタムコントロール(Thumb)にContentPresenterを使用
CustomControl.xaml(親指)
<Thumb x:Class="StackOverflow.CustomControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Thumb.Template>
<ControlTemplate>
<ContentPresenter/>
</ControlTemplate>
</Thumb.Template>
</Thumb>
MainWindow.xaml
<Window x:Class="StackOverflow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:StackOverflow">
<local:CustomControl>
<!--Shape, Image or TextBlock-->
</local:CustomControl>
</Window>
Thumb'は、私はあなたが持っているつもりだと思う、ContentControl' 'から派生していないので'あなたのクラスに 'Object'型の' Content'依存性プロパティを与え、カスタムコントロールクラスに 'ContentProperty(" Content ")[DefaultProperty(" Content ")]'という2つの属性を与えます。 –
...あなたの親クラスが実際に呼び出されたものであれば、 'ControlTemplate'' TargetType =" local:CustomControl "'を与えます。 –