I have following code:
<ControlTemplate x:Key="ViewItemTemplate"
TargetType="ListViewItem">
<StackPanel Orientation="Horizontal">
<CheckBox Margin="0,0,3,0" x:Name="CkBox">
<CkBox.IsChecked>
<Binding Path="IsSelected"
Mode="TwoWay">
<Binding.RelativeSource>
<RelativeSource Mode="TemplatedParent" />
</Binding.RelativeSource>
</Binding>
</CkBox.IsChecked>
<DataTrigger Binding="{Binding InvalidForeground}" Value="true">
<Setter TargetName="CkBoxVisual" Property="Foreground" Value="#999999"/>
</DataTrigger>
</CheckBox>
<ContentPresenter />
</StackPanel>
</ControlTemplate>
How can i bind InvalidForeground? I looked online for many example they tell to use DataTemplate. But when i add DataTemplate above StackPanel i get errors? Am i doing something wrong?
I am trying to bind InvalidForeground so i can add some code to it. I am getting an error: Cannot resolve symbol ‘InvalidForeground’ due to unknown DataContext.
InvalidForeground must be the property in the DataContext of the Control whose template the above code is.I hope this will help