小编Art*_*rov的帖子

WPF在触发器中设置边框背景

我需要创建一个触发器,当MouseEnter发生时,它将更改Border背景属性.我做了以下事情:

<Border Width="20" Height="30" Focusable="True">
        <Border.Background>
            <LinearGradientBrush>
                <LinearGradientBrush.GradientStops>
                    <GradientStop Color="Aquamarine" Offset="0"/>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Border.Background>
        <Border.Style>
            <Style TargetType="{x:Type Border}">
                <Style.Triggers>

                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background">
                            <Setter.Value>
                                <LinearGradientBrush>
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="Aquamarine" Offset="0"/>
                                        <GradientStop Color="Beige" Offset="0.2"/>
                                        <GradientStop Color="Firebrick" Offset="0.5"/>
                                        <GradientStop Color="DarkMagenta" Offset="0.9"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Border.Style>
    </Border>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.谢谢.

wpf triggers background

19
推荐指数
1
解决办法
2万
查看次数

XAML中的触发器

我有一个带标签的控件..还有一个布尔依赖属性"IsLink"...所以,如果IsLink = true,我需要将蓝色Foreground和Cursor作为"Hand".

我可以使用绑定,但在这种情况下我需要编写两个转换器(BoolToCursor和BoolToForeground),但我太懒了:)

所以,我试过这样的事情:

<Label Name="lblContent" VerticalAlignment="Center" FontSize="14">
    <Label.Style>
        <Style TargetType="Label">
            <Style.Triggers>
                <Trigger SourceName="myControl" Property="IsLink" Value="True">
                     <!--Set properties here-->
                </Trigger>
            </Style.Triggers>
        </Style>
    </Label.Style>
    label's text
</Label>
Run Code Online (Sandbox Code Playgroud)

但它不起作用......任何想法,先生们?:)

c# wpf xaml binding

7
推荐指数
1
解决办法
1万
查看次数

填充"角落"边界

希望我的问题很容易:)我有BORDER作为主要容器,有一些角半径.里面有一个GRID,如果我想为网格设置一些背景颜色 - 角落外面有一个丑陋的填充部分......

那么,我怎样才能将BORDER设置为全局容器,内部的一切都留在里面?

谢谢!

wpf xaml visual-studio-2010

3
推荐指数
1
解决办法
2788
查看次数

更改XAML中的绑定值

我需要在XAML中进行一些复杂的绑定.我有一个DependencyProperty typeof(double); 让我们来命名吧SomeProperty.在我控制的XAML代码中的某个地方,我需要使用整个SomeProperty值,只有一半,某处SomeProperty/3,等等.

我该怎么做:

<SomeControl Value="{Binding ElementName=MyControl, Path=SomeProperty} / 3"/>
Run Code Online (Sandbox Code Playgroud)

:)

期待.

c# data-binding wpf xaml

2
推荐指数
1
解决办法
2510
查看次数

DevExpress GridControl行号

如何使用行号创建列?适用于默认WPF dataGrid的解决方案不适用于DevExpress ...

c# wpf devexpress gridcontrol

1
推荐指数
1
解决办法
9592
查看次数