Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Databinding problem
    primarykey
    data
    text
    <p>I'm new to WPF and I have some difficulties when I'm trying to populate a ListView with a list of custom objects.</p> <pre><code>internal class ApplicationCode { public int Code { get; set; } public IEnumerable&lt;string&gt; InstrumentCodes { get; set; } } </code></pre> <p>I have a list of ApplicationCode which I set to ItemsSource to a ListView. I need to display the ApplicationCode.Code as a string and for the rest of the columns a check box which can be checked/unchecked depending if the column name is contained in the InstrumentCodes collection.</p> <p>In order to set the check box I use a converter on databinding:</p> <pre><code>&lt;DataTemplate x:Key="InstrumentCodeTemplate"&gt; &lt;CheckBox IsEnabled="False" IsChecked="{Binding Mode=OneTime, Converter={StaticResource InstrumentSelectionConverter}}" /&gt; &lt;/DataTemplate&gt; </code></pre> <p>The problem I have is because I can't know which is the current column at the time of cell data binding and I can't set the ConverterParameter.</p> <pre><code>public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ApplicationCode appCode = value as ApplicationCode; return appCode != null &amp;&amp; appCode.InstrumentCodes.Contains(parameter.ToString()); } </code></pre> <p>Small example:</p> <pre><code> Id | Code1 | Code3 | Code4 -------------------------------- 123 | True | False | True </code></pre> <p>Data for row 1: ApplicationCode.InstrumentCodes {Code1, Code4}</p> <p>There is a way to find out the column index or name? Or there is another way to solve this problem? </p>
    singulars
    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.
 

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