This is a migrated thread and some comments may be shown as answers.

ChildWindow close doesn't correctly return IsEnabled state when Mode=TwoWay is set

3 Answers 28 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 22 Jun 2017, 07:03 PM

I think this bug is a core problem with Microsoft SL5 as the issue surfaces with Microsoft controls as well as Telerik controls.  But I thought I'd bring it to attention as it might be valuable information for other developers to garnish.

Situation:

1.  From a UserControl have a control (button, RadComboBox, etc.) that has the IsEnabled bound to an MVVM class property ... example

<telerik:RadComboBox x:Name="RentalTypeComboBox" Grid.ColumnSpan="2" Grid.Column="6" Grid.Row="1" Style="{StaticResource DomicoRadComboBoxFill}" DisplayMemberPath="RentalTypeName" ItemsSource="{Binding Path=RentalTypes, Mode=TwoWay}" SelectedItem="{Binding Path=RentalType, TargetNullValue='None', FallbackValue='N/A', Mode=TwoWay}" IsEnabled="{Binding Path=RentalTypeSelectionEnabled, Mode=TwoWay}"/>

2.  Now instantiate (show) a ChildWindow ... this effectively disables the background by setting IsEnabled=False for all controls in the UserControl.

3.  Once the user initiates the closing of the ChildWindow all the background control in UserControl should be reset to "IsEnabled" and then their current state gets re-applied.  This works on all controls except when IsEnabled is used and it's Mode=TwoWay.  If Mode=TwoWay the control will stay in a disabled state.  Remove the Mode property like below and it works as expected:

<telerik:RadComboBox x:Name="RentalTypeComboBox" Grid.ColumnSpan="2" Grid.Column="6" Grid.Row="1" Style="{StaticResource DomicoRadComboBoxFill}" DisplayMemberPath="RentalTypeName" ItemsSource="{Binding Path=RentalTypes, Mode=TwoWay}" SelectedItem="{Binding Path=RentalType, TargetNullValue='None', FallbackValue='N/A', Mode=TwoWay}" IsEnabled="{Binding Path=RentalTypeSelectionEnabled}"/>

NOTE: It's important to understand that this issue WILL NOT surface under VS 2015 debug session, this issue ONLY surfaces when deployed to a real IIS web server.  So if anyone tries to replicate under VS 2015 you will NOT be able to, you MUST deploy to an IIS web server to see this issue of IsEnabled with binding Mode=TwoWay when using showing a ChildWindow from a UserControl.

Cheers, Rob.

 

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 27 Jun 2017, 02:01 PM
Hello Rob,

Thank you for sharing this scenario. 

I played around with the ChildWindow control and indeed that seems as a Silverlight issue. I was able to reproduce it with a single ContentControl and a Button. For whom that would be interesting I attached the example used for testing. If you deploy this in IIS, the issue appears.

I also found some information on the internet about this scenario and you can work it around by setting the IsEnabled property of the view model manually in the Closed event of the ChildWindow. For example:
var w = new ChildWindow();
w.Closed += (s, args) => { (this.DataContext as MainViewModel).IsEnabled = true; };
w.Show();

Regards,
Martin Ivanov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Rob Ainscough
Top achievements
Rank 1
answered on 28 Jun 2017, 10:13 PM

Martin,

Glad you were able to replicate it, I doubt Microsoft will fix the issue.  Along similar lines I found an issue with RadMaskedNumericInput that exhibited the same behavior with Mode=TwoWay but on the "Value" property and this time around the issue would trigger in VS 2015 debug session but would NOT trigger when deployed to an IIS web server.

For some reason the .Show() would cycle thru all the controls for "get" but whenever RadMaskedNumericInput binding was found it would operate the Get and then try to Set a default value to 0.0??  Triple checked my code and nothing was being assigned to the bound property, so it appears somewhere in the RadMaskedNumericInput code you folks are setting the Value property = 0.0.  The ONLY happens with the RadMaskedNumericInput and Mask property set.

Cheers, Rob.

0
Martin Ivanov
Telerik team
answered on 03 Jul 2017, 10:32 AM
Hi Rob,

I tested this with RadMaskedNumericInput, but I wasn't able to reproduce the issue. Can you prepare some runnable code and send it over so I can check it? Alternatively, you can open a new support ticket and share a project there.

Regards,
Martin Ivanov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Rob Ainscough
Top achievements
Rank 1
Share this question
or