我有一个文本前景色为白色,背景色为透明的控件。
之后这个用户控件将被添加到带有实际背景颜色的不同控件中。
然而,在设计过程中,由于VS 2010中的白色前景和白色背景,我无法看到任何东西。是否有任何方法只在设计时定义不同的颜色?
我已经尝试过这个:
if (System.ComponentModel.DesignerProperties.IsInDesignTool)
{
LayoutRoot.Background = new SolidColorBrush(Colors.Blue);
}
但是这并不起作用。有什么提示吗?
更新:
我不明白这对你们如何起作用。我创建了一个新的Silverlight 4.0应用程序,并将这行代码插入到构造函数中:
public MainPage()
{
InitializeComponent();
LayoutRoot.Background = new SolidColorBrush(Colors.Blue);
}
<UserControl x:Class="SilverlightApplication3.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot">
</Grid>
</UserControl>
当我进入设计师时,我仍然没有看到它是蓝色的。并且我甚至没有任何isInDesignTime条件。我在这里缺少什么?
谢谢, Kave
d:DesignStyle
属性。 - Shahin Dohan