English 中文(简体)
加入女权论坛风格的法典
原标题:Add code to a style in WPF

我有几个项目,在这些项目中,我想总是以同样的方式行事。 为了像背景一样宽恕,它很出色,但我还要补充基调活动手(在这种情况下,就是焦点活动)。

这是可能的,如果是的话?

Thanks.

Edit: 这里的一个例子是:

<Style x:Key="BaseComboBox" TargetType="ComboBox">
    <Setter Property="FontSize" Value="12"></Setter>
    <Setter Property="Foreground" Value="Black"></Setter>
    <Setter Property="FontFamily" Value="Arial"/>
    <Setter Property="HorizontalAlignment" Value="Stretch"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
    <Setter Property="Height" Value="22"/>
    <Setter Property="Margin" Value="5,0,5,0"/>       
    <Setter Property="IsEditable" Value="True" />
    <Add LostFocus Event that will validate the selection here...>
</Style>

我的所有风格都在资源理论中。

最佳回答
<Style x:Key="MyStyle">
    <EventSetter Event="Control.GotFocus" Handler="Control_GotFocus"></EventSetter>
</Style>
问题回答

为什么不使用共同方法在你的项目中进行验证,而不是制造一些 we?

阅读





相关问题
Creating a Style in code behind

Does anyone know how to create a wpf Style in code behind, I can t find anything on the web or MSDN docs. I have tried this but it is not working: Style s = new Style(typeof(TextBlock)); s....

WPF Custom Themes

I have a simple question which is giving me some difficulty. I have downloaded a custom them for WPF of the net. Now i want to apply this theme to my App instead of the default one. How do i do that,...

Is it sometimes bad to use <BR />?

Is it sometimes bad to use <BR/> tags? I ask because some of the first advice my development team gave me was this: Don t use <BR/> ; instead, use styles. But why? Are there negative ...

WPF - How to apply effect to a cropped image?

I have an Image being clipped like so: <Image Width="45" Grid.Column="0" Source="{Binding Photo}"> <Image.Clip> <RectangleGeometry Rect="0,0,45,55" RadiusX="8" RadiusY="8" /...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签