Note that there are some explanatory texts on larger screens.

plurals
  1. POIValueConverter removing underlying value of enum(int)
    primarykey
    data
    text
    <p>I'm passing an <code>Enum</code> with underlying value (<code>int</code>) as a parameter from <code>XAML</code> to an <code>IValueConverter</code>. The idea is to use the <code>Enum</code> value to iterate against a list to check if the value exists &amp; return a <code>Visibility</code> <code>enum</code>. The list is of type <code>int</code>. But when passing the <code>Enum</code> to the <code>converter</code>, I cannot cast the <code>Enum</code> back to an <code>int</code>. Peering into the parameter with 'Quick Watch', I cannot see the underlying value or any value at all.</p> <p>Enum e.g. </p> <pre><code>public class Operations { public enum Reporting { ReportAccounts = 101, ReportEngineering = 102, ReportSoftware = 103, ReportPR = 104, ReportCRM = 105 } public enum Editing { EditUser = 201, EditAccess = 202, EditView = 203 } } </code></pre> <p>XAML e.g. </p> <pre><code>Visibility={Binding Converter={StaticResource VisibilityConverter}, ConverterParameter={x:Static Operations:Reporting.ReportAccounts}} </code></pre> <p><code>IValueConverter</code> e.g.</p> <pre><code>public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { bool visibility = OperationList.Exists(list =&gt; list.Id == (int)parameter); if (visibility == true) { return Visibility.Visible; } else { return Visibility.Collapsed; } } </code></pre> <p>I would like to know if there is any way of retaining or retrieving the underlying value of an enum when it is passed to an <code>IValueConverter</code>.</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.
 

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