2010-02-21 2 views
4
<Window x:Class="tests.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="350" Width="525" Background="Red" Foreground="Cyan"> 
    <StackPanel VerticalAlignment="Center"> 
     <Button>123</Button> 
     <TextBlock>123</TextBlock> 
     <TextBox>123</TextBox> 
    </StackPanel> 
</Window> 

위 코드에서 TextBlock 만 전경색과 배경색을 "상속"합니다. Button과 TextBox에도 이러한 색상이 있어야하지 않습니까? 왜 그들은 그것을 가지고 있지 않습니까? alt text http://img707.imageshack.us/img707/8014/5uslgmbzkbyurgwuwgqtzv2.png일부 자식 요소 만 부모가 정의한 속성을 갖는 이유

답변

-1
<Button background="{Binding ElementName=stackPanel1,Path=Background}" .../> 
관련 문제