Note that there are some explanatory texts on larger screens.

plurals
  1. POLogic in ListView For Binding Items
    primarykey
    data
    text
    <p>I have a three arrays of data that will populate a <code>ListView</code> that has <code>DisplayMemberBinding</code></p> <p>Can I add logic to the Binding item to change the <code>ListView</code> Foreground or Background propery of the cell?</p> <p>Xaml:</p> <pre><code>&lt;Grid&gt; &lt;ListView x:Name="carList" VerticalAlignment="Top"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn Header="Car" DisplayMemberBinding="{Binding Name}" Width="Auto"/&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Make}" Header="Make" Width="Auto"/&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Year}" Header="Year" Width="Auto"/&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; &lt;Button x:Name="generate" Content="Parse" Click="generate_Click" Margin="0,5,5,5" DockPanel.Dock="Top" VerticalAlignment="Bottom" HorizontalAlignment="Right"/&gt; &lt;/Grid&gt; </code></pre> <p>CS:</p> <pre><code>public MainWindow() { InitializeComponent(); } public class Car { public string Name { get; set; } public string Make { get; set; } public string Year { get; set; } } private void generate_Click(object sender, RoutedEventArgs e) { int i = 0; string[] name = { "Sentra", "IS", "Camry" }; string[] make = { "Nissan", "Lexus", "Toyota" }; string[] year = { "2003", "2011", "2013" }; foreach (string s in name) { Car car = new Car(); car.Name = name[i]; car.Make = make[i]; car.Year = year[i]; if (year[i] == "2013") { //Do something here //Make bold, change color, etc. } carList.Items.Add(car); i++; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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