Click here to Skip to main content
15,884,099 members

Comments by Leung Yat Chun (Top 18 by date)

Leung Yat Chun 29-May-14 12:14pm View    
Hello kartikguha,

Your code is binding to the DataContext of parent TabItem property, not the TabItem.
I think if you want to bind to the dependency property, you have to use Trigger instead of DataTrigger, e.g.
http://msdn.microsoft.com/en-us/library/ms743015%28v=vs.110%29.aspx

Regards
Joseph Leung
Leung Yat Chun 22-May-14 5:20am View    
I think Fahad is using Modern UI on CodePlex.
Leung Yat Chun 5-Jan-14 3:32am View    
You can also setup a binding to the text (Low,Medium,High) and add a trigger in the style of ListViewItem...instead of color.
Replace Trigger with DataTrigger to bind to the ViewModel.

<ListView>
<ListView.Resources>
<Style TargetType="ListViewItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Style.Triggers>
<Trigger Property="Content" Value="Low">
<Setter Property="Foreground" Value="Green" />
</Trigger>
<Trigger Property="Content" Value="Medium">
<Setter Property="Foreground" Value="Blue" />
</Trigger>
<Trigger Property="Content" Value="High">
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.Resources>

<ListViewItem>Low</ListViewItem>
<ListViewItem>Medium</ListViewItem>
<ListViewItem>High</ListViewItem>
</ListView>
Leung Yat Chun 22-Dec-13 14:18pm View    
I don't know how to do it without using xaml, but I think you can inherited from ContentControl instead.
public class Control1 : ContentControl
{ public override void OnApplyTemplate() { base.OnApplyTemplate(); Content = new Grid(); } }
Leung Yat Chun 5-Dec-13 2:27am View    
Or better yet, use MouseButtonEventArgs.ClickCount.