View Issue Details

IDProjectCategoryView StatusLast Update
0003429NoesisGUIC++ SDKpublic2024-12-26 19:08
Reporternikobarli Assigned Tosfernandez  
PrioritynormalSeveritymajor 
Status resolvedResolutionfixed 
Product Version3.2.3 
Target Version3.2.7Fixed in Version3.2.7 
Summary0003429: RadioButton selection cannot be controlled correctly from code when using OneWay Binding.
Description

Please find the patch to reproduce the problem below.

The patch creates a group of two radio buttons and toggle the selection using a button.
The two radio buttons IsChecked property is bound using OneWay binding and the toggling between radio button 1 and 2 is done through code (command of the button).

After clicking the button for several times, none of the buttons is selected, which is not the expected behavior.

Steps To Reproduce

Please apply the attached patch, build Noesis solutions, and run the Commands project.

Attached Files
Test_OneWayBinding.patch (2,921 bytes)   
Index: Native/Src/Packages/Samples/Commands/Data/MainWindow.xaml
===================================================================
--- Native/Src/Packages/Samples/Commands/Data/MainWindow.xaml	(revision 173884)
+++ Native/Src/Packages/Samples/Commands/Data/MainWindow.xaml	(working copy)
@@ -19,7 +19,7 @@
             Background="#801C1F21" BorderBrush="#40101611" BorderThickness="1" CornerRadius="5"
             HorizontalAlignment="Center" VerticalAlignment="Center">
       <StackPanel Orientation="Vertical">
-        <DockPanel>
+        <!--<DockPanel>
           <TextBlock Text="Input:" Width="80" VerticalAlignment="Center"/>
           <TextBox Text="{Binding Input, Mode=TwoWay}"/>
         </DockPanel>
@@ -33,7 +33,12 @@
         <Viewbox Height="50" Margin="0,20,0,0">
           <TextBlock TextAlignment="Center" Text="{Binding Output}"
                      FontSize="28" Foreground="White"/>
-        </Viewbox>
+        </Viewbox>-->
+
+        <RadioButton Content="1" IsChecked="{Binding Flag1, Mode=OneWay}"/>
+        <RadioButton Content="2" IsChecked="{Binding Flag2, Mode=OneWay}"/>
+        <Button Content="Test" Command="{Binding TestCmd}"/>
+        
       </StackPanel>
     </Border>
   </Viewbox>
Index: Native/Src/Packages/Samples/Commands/Src/Main.cpp
===================================================================
--- Native/Src/Packages/Samples/Commands/Src/Main.cpp	(revision 173884)
+++ Native/Src/Packages/Samples/Commands/Src/Main.cpp	(working copy)
@@ -26,6 +26,7 @@
 using namespace Noesis;
 using namespace NoesisApp;
 
+#pragma warning( disable : 4100 )
 
 namespace Commands
 {
@@ -37,6 +38,7 @@
     ViewModel()
     {
         _command.SetExecuteFunc(MakeDelegate(this, &ViewModel::SayHello));
+        _testCmd.SetExecuteFunc(MakeDelegate(this, &ViewModel::ChangeFlag));
     }
 
     const char* GetInput() const
@@ -85,7 +87,27 @@
         }
     }
 
+    bool GetFlag1(void) const {
+        return _flag;
+    }
+    bool GetFlag2(void) const {
+        return !_flag;
+    }
+    const DelegateCommand* GetTestCmd() const
+    {
+        return &_testCmd;
+    }
+    void ChangeFlag(BaseComponent* param_)
+    {
+        _flag = !_flag;
+        OnPropertyChanged("Flag1");
+        OnPropertyChanged("Flag2");
+    }
+
 private:
+    bool _flag = true;
+    DelegateCommand _testCmd;
+
     DelegateCommand _command;
     char _input[256] = "";
     char _output[256] = "";
@@ -95,6 +117,10 @@
         NsProp("Input", &ViewModel::GetInput, &ViewModel::SetInput);
         NsProp("Output", &ViewModel::GetOutput, &ViewModel::SetOutput);
         NsProp("SayHelloCommand", &ViewModel::GetSayHelloCommand);
+
+        NsProp("Flag1", &ViewModel::GetFlag1);
+        NsProp("Flag2", &ViewModel::GetFlag2);
+        NsProp("TestCmd", &ViewModel::GetTestCmd);
     }
 };
 
Test_OneWayBinding.patch (2,921 bytes)   
PlatformWindows

Relationships

related to 0002434 resolvedsfernandez ToggleButton with one way binding 

Activities

sfernandez

sfernandez

2024-12-26 19:08

manager   ~0010228

Fixed in changeset 14847

Issue History

Date Modified Username Field Change
2024-06-24 05:50 nikobarli New Issue
2024-06-24 05:50 nikobarli File Added: Test_OneWayBinding.patch
2024-06-24 12:38 sfernandez Relationship added related to 0002434
2024-06-24 12:38 sfernandez Assigned To => sfernandez
2024-06-24 12:38 sfernandez Status new => assigned
2024-06-24 12:38 sfernandez Target Version => 3.2.5
2024-10-24 16:43 sfernandez Target Version 3.2.5 => 3.2.6
2024-11-22 18:18 jsantos Target Version 3.2.6 => 3.2.7
2024-12-26 19:08 sfernandez Status assigned => resolved
2024-12-26 19:08 sfernandez Resolution open => fixed
2024-12-26 19:08 sfernandez Fixed in Version => 3.2.7
2024-12-26 19:08 sfernandez Note Added: 0010228