2010-08-20 38 views

回答

0

使用相對源綁定:

BorderBrush="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=BorderBrush}" 
0

您可以使用Border標籤得到窗口邊框,您的用戶控件,就像這樣:

<UserControl x:Class="WpfApplication1.UserControl1" ------->   
<Border Width="310" CornerRadius="5" BorderBrush="LightBlue" BorderThickness="1"> 
<Grid VerticalAlignment="Center"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="30"/> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="40"></ColumnDefinition> 
     <ColumnDefinition Width="*"></ColumnDefinition> 
    </Grid.ColumnDefinitions> 
    <Label Content="File" Grid.Column="0" Height="22" Grid.Row="0" ></Label> 
    <Button Content="Browse..." Grid.Column="1" Grid.Row="0" Height="25" Width="70" HorizontalAlignment="Right" Margin="1,1,5,1" SnapsToDevicePixels="True"></Button> 
</Grid> 
    </Border> 
</UserControl> 
0

您可以使用用戶控件的內容窗口。

如果你喜歡

Window w = new Window() {Content=new **YourUserControlHere**,Width=400,Height =400,... }; 
w.ShowDialog(); 

CheckHere

相關問題