Hello,
Welcome to Microsoft Q&A!
Exception thrown: 'System.Runtime.InteropServices.COMException' in Sudoku_Experimental.exe WinRT information: The object is immutable.
Based on the BindingExpression.ParentBinding method, the Remarks Part of the document, it mentions
You can't set the property values of a Binding object after that binding has been attached to a target element and target property. If you attempt this you'll get a run-time exception. So when you tried to set its ConverterParameter, it throwed the above exception.
If you want to update its ConverterParameter, you can only create a new Binding to attach to your element. Or you can add a property in your Converter to replace the role of ConverterParameter. For example:
public class MyConverter : IValueConverter
{
public string MyParameter { get; set; }
public object Convert(object value, Type targetType, object parameter, string language)
{
if (MyParameter == "UnSelected") {
return "UnSelected";
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
.xaml:
<Page.Resources>
<local:MyConverter MyParameter="UnSelected" x:Key="Converter1"/>
</Page.Resources>
.cs:
When you tried to change the property:
MyConverter conv = this.Resources["Converter1"] as MyConverter;
conv.MyParameter = "Selected";