My MultiDataTrigger
should change the properties of a TabItem
if both values are as expected. One of the values is a Property
from the TabItem
, the other one is a Properties.Settings.Default
property.
<!--<App xmlns:prop="clr-namespace:MyApp.Properties"... -->
<DropShadowEffect x:Key="Glow.Foreground.Large" ShadowDepth="0" Color="WhiteSmoke"
Opacity="1" BlurRadius="10" RenderingBias="Quality"/>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid Name="Panel" Background="Transparent">
<Border Name="ContentBorder"
BorderBrush="#FFD4D4D4" BorderThickness="0">
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center" Effect="{x:Null}"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="10,2"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Panel"
Property="Background"
Value="#FFFAFAFA" />
<Setter Property="Foreground"
Value="#FF2B579A" />
<Setter TargetName="ContentBorder"
Property="BorderThickness"
Value="1,1,1,0" />
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Property="IsSelected" Value="False"/>
<Condition Binding="{Binding
Source={x:Static prop:Settings.Default},
Path=EditorExtendChrome}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter TargetName="ContentBorder"
Property="Effect"
Value="{StaticResource Glow.Foreground.Large}" />
<Setter TargetName="ContentBorder"
Property="Background"
Value="#7FFFFFFF"/>
</MultiDataTrigger>
<Trigger Property="IsMouseOver" Value="True"
SourceName="Panel">
<Setter Property="Foreground"
Value="#FF2B579A" />
<Setter Property="Background"
Value="#FFFAFAFA" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<!--Default Values-->
<Setter Property="FontFamily" Value="Segoe UI Semilight"/>
</Style>
I'm following this post , yet the error "You must have a non-null value for 'Binding'" stills persists.
The normal Settings
class does not provide WPF-compatible property change notifications. It's likely that's why your code doesn't work. But without a good, minimal , complete code example that reliably reproduces the problem, there is no way to know for sure.
The Default
property will be null
early in the execution of the program, and so without property change notifications, WPF will only have ever seen the null
value, which of course is of no use to it.
Also note that, per the SO answer you're referencing, the Condition
object for a MultiDataTrigger
should specify Binding
and not Property
.
If the above does not address your concern, please provide a better code example and also be more specific about the error: when do you see this error, how is it reported, and what is the full stack trace for the error (if available)? Note that with a good code example, then even without direct support for property change notifications, it's possible an answer that solves your exact scenario could be provided.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.