Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This <a href="http://blogs.msdn.com/b/mim/archive/2013/03/11/tips-winrt-converter-parameter-binding.aspx" rel="nofollow">blog post</a> explains a work around for the problem. The idea is to create a <a href="http://msdn.microsoft.com/en-us/library/ms752914%28v=vs.110%29.aspx" rel="nofollow">dependency property</a> on your converter. You can then bind your <code>StoreId</code> to this, instead of using the <code>ConverterParameter</code>.</p> <p>So on your <code>UserIdToNameConverter</code>, you need to inherit from <code>DependencyObject</code>, and add the dependency property:</p> <pre><code>public class UserIdToNameConverter : DependencyObject, IValueConverter { public string StoreId { get { return (string) GetValue(StoreIdProperty); } set { SetValue(StoreIdProperty, value); } } public static readonly DependencyProperty StoreIdProperty = DependencyProperty.Register("StoreId", typeof (string), typeof (UserIdToNameConverter), new PropertyMetadata(string.Empty)); public object Convert(object value, Type targetType, object parameter, string language) { //Your current code //Can now use StoreId instead of ConverterParameter } public object ConvertBack(object value, Type targetType, object parameter, string language) { //Same as above; } } </code></pre> <p>You can then bind to this dependency property within your view's resources:</p> <pre><code>&lt;UserControl.Resources&gt; &lt;UserIdToNameConverter x:Key="UserIdToNameConverter" StoreId="{Binding StoreId}"/&gt; &lt;/UserControl.Resources&gt; </code></pre> <p>This is assuming your view's <code>DataContext</code> is set to the <code>CustomersViewModel</code> where it can find the <code>StoreId</code> property. You can then use the converter the same way as you have in your question.</p> <p>As a side note, it won't work if you create the converter within the <code>ItemTemplate</code> instead of inside the <code>Resources</code>. See the blog post for more information. All credit goes to the blog's author, Sebastien Pertus.</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. 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