[IronPython] Silverlight - Cannot save value from target back to source
Lukas Cenovsky
cenovsky at bakalari.cz
Thu Sep 2 20:39:22 CEST 2010
Following my binding experiments in WPF, I tried to convert the sample
into Silverlight and I hit another binding errors there.
When I bind anything else than string, I receive an error when the
target value is changed and the source should be updated. This happens
in all IronPython versions (2.6.1 on .Net 2.0 and 4, 2.7a1).
Here is the code I use (the whole source is attached):
@property
@clrtype.accepts()
@clrtype.returns(System.Nullable[System.Boolean])
def filtered(self):
return self._filtered
@filtered.setter
@clrtype.accepts(System.Nullable[System.Boolean])
@clrtype.returns()
def filtered(self, value):
self._filtered = value
self.OnPropertyChanged('filtered')
As you can see I tried to use System.Nullable[System.Boolean] instead of
bool but it did not help. I also tried to use converter and convert the
value to this type (System.Nullable[System.Boolean](value)) but that did
not help either. All resulted in the following exception for bool type.
System.Windows.Data Error: Cannot save value from target back to source.
BindingExpression: Path='filtered' DataItem='Mountains'
(HashCode=2058916); target element is 'System.Windows.Controls.CheckBox'
(Name=''); target property is 'IsChecked' (type
'System.Nullable`1[System.Boolean]')..
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Security.VerificationException: Operation could destabilize the
runtime.
at Mountains.filtered(Nullable`1 value)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo
method, Object target, Object[] arguments, SignatureStruct& sig,
MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object
value, BindingFlags invokeAttr, Binder binder, Object[] index,
CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object
value, Object[] index)
at System.Windows.CLRPropertyListener.set_Value(Object value)
at System.Windows.PropertyAccessPathStep.set_Value(Object value)
at System.Windows.Data.BindingExpression.UpdateValue().
The similar exception is raised for float or System.Double.
I have found an old issue similar to this:
http://ironpython.codeplex.com/workitem/16831?ProjectName=ironpython
Any workaround would be nice for this bug :-)
--
-- Lukáš
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: app.py
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100902/3c03b15c/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: app.xaml
Type: application/xaml+xml
Size: 370 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100902/3c03b15c/attachment.bin>
More information about the Ironpython-users
mailing list