2010-02-21 22 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}" .../> 
相關問題