我在禁用时对文本框应用颜色时遇到问题,
acctualy我有数据网格,我用"#E0E4E5"
颜色着色了一行。我希望保留文本框的颜色,因为行的颜色是("#E0E4E5"
)。
接下来我做了什么:
我将属性设置为行AlternatingRowBackground="#E0E4E5"
,然后将此颜色设置为行的背景颜色。
之后我做了下一步,我为我的文本框创建了样式,因为wpf中的默认值看起来不太好,它有一些阴影等,所以这是我的文本框自定义样式:
<Style x:Key="TextBoxStyle1" TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="#E0E4E5" />
<Setter Property="BorderBrush" Value="#E0E4E5" />
<Setter Property="BorderThickness" Value="1.5" />
</Trigger>
</Style.Triggers>
<Setter Property="BorderBrush" Value="#0091EA"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
正如你所看到的那些家伙有这段代码(triger)说好了,当你被禁用时,让你的背景颜色像这样,边框刷是这样的:
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="#E0E4E5" />
<Setter Property="BorderBrush" Value="#E0E4E5" />
<Setter Property="BorderThickness" Value="1.5" />
</Trigger>
</Style.Triggers>
以下是它的外观示例:
因为可以看到我对它们都应用了相同的颜色&#34;#E0E4E5&#34;但是不知道它们是不同的,所以当我的文本框禁用它成为&#34;#E0E4E5&#34;时,我怎么能这样做呢? &lt; - color ..
我还必须注意,如果我改变边框画笔的颜色,它就能正常工作。例如,当它们被禁用时,我将它们设置为文本框和边框刷为红色,我得到了这个:
所以边框刷已更改,但背景没有。
谢谢你们, 干杯
答案 0 :(得分:1)
删除Setter
中的ControlTemplate
Background
,SystemColors.ControlBrushKey
在TextBox
被禁用时将<Style x:Key="TextBoxStyle1" TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="#E0E4E5" />
<Setter Property="BorderBrush" Value="#E0E4E5" />
<Setter Property="BorderThickness" Value="1.5" />
</Trigger>
</Style.Triggers>
<Setter Property="BorderBrush" Value="#0091EA"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
设置为if(req.body.parent.name == undefined) { //That means parent is a string
req.checkBody('parent', 'Parent Name and group name should be different.').checkEquality(name);
} else { //That means parent is an object
req.checkBody('parent.name', 'Parent Name and group name should be different.').checkEquality(name);
}
:
result = [elements[i:i+5] for i in range(0,len(elements),5)]