我需要创建一个触发器,当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)
但它不起作用.谢谢.
我有一个带标签的控件..还有一个布尔依赖属性"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)
但它不起作用......任何想法,先生们?:)
希望我的问题很容易:)我有BORDER作为主要容器,有一些角半径.里面有一个GRID,如果我想为网格设置一些背景颜色 - 角落外面有一个丑陋的填充部分......
那么,我怎样才能将BORDER设置为全局容器,内部的一切都留在里面?
谢谢!
我需要在XAML中进行一些复杂的绑定.我有一个DependencyProperty typeof(double); 让我们来命名吧SomeProperty.在我控制的XAML代码中的某个地方,我需要使用整个SomeProperty值,只有一半,某处SomeProperty/3,等等.
我该怎么做:
<SomeControl Value="{Binding ElementName=MyControl, Path=SomeProperty} / 3"/>
Run Code Online (Sandbox Code Playgroud)
:)
期待.
如何使用行号创建列?适用于默认WPF dataGrid的解决方案不适用于DevExpress ...
wpf ×5
c# ×3
xaml ×3
background ×1
binding ×1
data-binding ×1
devexpress ×1
gridcontrol ×1
triggers ×1