WPF の質問です。何をグーグルで検索すればよいかわかりません。
私はユーザーコントロールを持っています:
<UserControl x:Class="MyProj.MyControl"
x:Name="Self"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button />
</UserControl>
私はこのように使用します:
<local:MyControl Background="Green" />
でも、背景は変わらないようです。ボタンの背景が変わっていないからです。ボタンの背景にユーザーコントロールの背景を使用したい。
私はこれを行うことができると思います:
<UserControl x:Class="MyProj.MyControl"
x:Name="Self"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button Background="{Binding Path=Background, ElementName=Self" />
</UserControl>
しかし、Control および ContentControl から継承されたすべてのプロパティ (ToolTip、BorderThickness、BorderBrush など) をボタンに適用したいと考えています。
それで、これの代わりに何ができますか:
<UserControl x:Class="MyProj.MyControl"
x:Name="Self"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button Background="{Binding Path=Background, ElementName=Self"
ToolTip="{Binding Path=ToolTip, ElementName=Self"
BorderThickness="{Binding Path=BorderThickness, ElementName=Self"
BorderBrush="{Binding Path=BorderBrush, ElementName=Self"
...
...
...
... />
</UserControl>
?
(注: これは、多くのコントロールをホストする大きな UserControl の小さな (実際、私が管理できる最小の) 例です。)