Good Morning,
after resolving some problems with the Theme property and custom styles we now find out that XamCheckEditor has issues with a very special requirement we have currently: Setting the DataContext property of the xaml form at runtime. Remark: The xaml we bind is used as an adorner. Maybe thats the source of the problem?
In this case the data binding for the checked property will not work as intended.
Steps to reproduce:
- Define 2 checkboxes and a text editor:
<igEditor:XamCheckEditor Value="{Binding SomeBoolProperty}"/><CheckBox Grid.Column="1" IsChecked="{Binding SomeBoolProperty}"/><igEditor:XamTextEditor Grid.Column="2" Value="{Binding SomeBoolProperty}"/>
- Do not set a DataContext for the upper container. Instead, bind the DataContext property of the xaml window at runtime to some data source which has "SomeBoolProperty" defined (and set to true for example).
- You will notice that the windows checkbox will refresh its binding and show the checked state, whereas the XamCheckEditor does not follow. XamTextEditor, however also correctly shows "True" in its text area. Changing the windows control correctly shows False in the text editor.
I attach a screenshot of the result...
BR Florian
Hi Florian,
Thank you for your new post. I have been looking into your issue and it seems that on my side everything works as expected. I am attaching a sample application(CheckEditor_DataContext.zip) that I used for my tests.
Please let me know, if I am missing something.
Hi Yanko,
thanks for the reply. You seem not to miss anything, I will now look into our code whats wrong there. Maybe we messed it up somewhere else....
Thank you for your reply. Let me know, if you find the reason for this behavior in your application.
Thank you for your reply. I am glad that you have managed to resolve your issue. The XamCheckEditor has more different structure that the others IG editors as it contains ValueEditorCheckBox. I believe that this is the main reason for the different behavior.
Let me know, if you need any further assistance on this matter.
Hi,
we found the issue: The DataContext property of the parent is not set correctly. We actually hit the problem described here. The ContentPresenter as a parent will modify it´s DataContext.
What is still unclear: Why some of the IG editors could sucessfully ignore the change and bound to the correct DataContext. Only CheckEditor was fooled ;)
Thank you for your feedback. Let me know, if you need any further assistance on this matter.
we tracked it down to be the problem in 1 form only and we found out that by re-applying the datacontext property on the level of the control (!) it works as intended. We put this in the style for XamCheckEditor:
<Setter Property="DataContext" Value="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
Also the windows standard Checkbox behaves oddly, it will follow changes on the viewmodel (getter being called), but if you check/uncheck it, the setter is never called. We verified this with breakpoints.
So something is obviously setting the DataContext and/or the Binding Mode in a wrong way. Will take ages to find but for the moment I can say it does not seem to be an IG issue ;)
BR