<ContentControl x:Class="Test.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="200" Height="200" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Rectangle Fill="Blue"/>
<ContentPresenter Grid.Row="1" Content="{TemplateBinding ContentControl.Content}" />
<Rectangle Fill="Yellow" Grid.Row="2"/>
</Grid>
</ContentControl>
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Test="clr-namespace:Test" Title="MainWindow" Height="350" Width="525">
<Grid>
<Test:MyControl2>
<Button/>
</Test:MyControl2>
</Grid>
</Window>
ボタンは、青色と黄色の四角形の間に表示されます。私のボタンがContentPresenter領域に表示されないのはなぜですか?
私は間違っていますか?
私はあなたがなぜあなたはコントロール内のボタンを配置していけない、ユーザーコントロール内にこのようにボタンを置くことができると思ういけませんか? – Habib