Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In my test, its work is done well. Please refer to the following code, which probably helps with you.</p> <p>What this code do is, when `Jours.Count' equals to "3", the Window background gets red color. XAML:</p> <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"&gt; &lt;Window.Resources&gt; &lt;Style TargetType="Grid"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding Jours.Count}" Value="3"&gt; &lt;Setter Property="Control.Background" Value="Red" /&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>CodeBehind:</p> <pre><code>public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); ITest test = new TestClass(); this.DataContext = test; } } interface ITest { ObservableCollection&lt;KeyValuePair&lt;DateTime, DateTime&gt;&gt; Jours { get; set; } } class TestClass : ITest { public TestClass() { Jours = new ObservableCollection&lt;KeyValuePair&lt;DateTime, DateTime&gt;&gt;(); Jours.Add(new KeyValuePair&lt;DateTime, DateTime&gt;(DateTime.Now, DateTime.Now)); Jours.Add(new KeyValuePair&lt;DateTime, DateTime&gt;(DateTime.Now, DateTime.Now)); Jours.Add(new KeyValuePair&lt;DateTime, DateTime&gt;(DateTime.Now, DateTime.Now)); } public ObservableCollection&lt;KeyValuePair&lt;DateTime, DateTime&gt;&gt; Jours { get; set; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload