Reputation: 61512
The designer shows a black border around the red background, but the actual application only shows the red background. What gives? How to force the black border to be visible?
Here’s the XAML for this window:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MinWidth="400" MinHeight="300"
TextOptions.TextFormattingMode="Display">
<DockPanel Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
<Button DockPanel.Dock="Top" Content="A button"
Padding="8,2" Margin="8" />
<Border DockPanel.Dock="Top" Height="10" BorderBrush="Black"
SnapsToDevicePixels="True" Background="Red" />
<Button DockPanel.Dock="Top" Content="A button"
Padding="8,2" Margin="8" />
</DockPanel>
</Window>
Upvotes: 3
Views: 4362
Reputation: 222
<Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource Gray4}"/>
</Border.BorderBrush>
Replace value of property "Color", using hex:
<Border.BorderBrush>
<SolidColorBrush Color="#FFD33B3B"/>
</Border.BorderBrush>
Upvotes: 0
Reputation: 755317
I'm not sure why the border is showing up in Design Mode but you can make it show up in the application by adding an explicit thickness
<Border DockPanel.Dock="Top" Height="10" BorderBrush="Black"
SnapsToDevicePixels="True" Background="Red" BorderThickness="1" />
Upvotes: 3
Reputation: 27250
My guess is that the default thickness of the border during runtime is 0 - possibly because of an inherited style in the application resource dictionary. Default styles inherited from a global resource dictionary often don't show up during design time.
Try explicitly setting the BorderThickness="1"
Upvotes: 3