Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Write a <code>Converter</code> that takes one of your "Product" objects....looks at the gender related data inside it, or does the gender determining logic, and then returns the gender string, "male" or "female".</p> <p>Then use it in your XAML to set the <code>TextBlock</code>:</p> <pre><code>&lt;StackPanel Height="197" HorizontalAlignment="Left" Margin="300,6,0,0" Name="StackPanel5" VerticalAlignment="Top" Width="285" DataContext="{Binding Source={StaticResource DetailViewPagos}}"&gt; &lt;StackPanel.Resources&gt; &lt;local:ProductToGenderConverter x:Key="prodtogenderconv"/&gt; &lt;/StackPanel.Resources&gt; &lt;ComboBox Height="23" Name="ComboBox2" Width="120" IsEditable="False" ItemsSource="{Binding Source={StaticResource ProductLookup}}"&gt; &lt;ComboBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Converter={StaticResource prodtogenderconv}}" /&gt; &lt;/DataTemplate&gt; &lt;/ComboBox.ItemTemplate&gt; &lt;/ComboBox&gt; </code></pre> <p></p> <pre><code>public class ProductToGenderConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { MyProduct prod = value as MyProduct; if (prod is for a male) // Pseudocode for condition return "male"; if (prod is for a female) // Pseudocode for condition return "female"; return null or ""; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } </code></pre> <p>Alternatively you could provide a ViewModel which wraps your Product object, which has a specific property that indicates the "genderness" of the Product...then create a collection of those objects for setting in your ComboBox...then you can use <code>DisplayMemberPath</code> to point to that property.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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