Wpf which radiobutton is checked




















As any other button the RadRadioButton exposes a Click event as well. The check state of the button can be manually controlled via its IsChecked property. By grouping the RadRadioButtons the user will be allowed to check only one button in the group.

In order to group several RadRadioButtons you can place them in the same layout panel see Example 5. IsBackgroundVisible - this property is of type bool and it controls the visibility of the background and the border of the RadRadioButton control when in normal state.

All Rights Reserved. From the open-source codes, we can find that the radio button auto checks the focus root as the group name scope:. Sorry, something went wrong. Before the issue is fixed, we can try to solve it by adding a MarkupExtension to generate the GroupName with a random name.

So different window instances have their own GroupName s and they will not affect each other over windows. Something must be wrong with your setup, if I add RadioButtons with GroupName to a window and then create two instances of the same window which obviously have the same group name since they have the same XAML they don't affect each other.

I'll have a look at your repro scenario. In my scene, you should:. Ok I think I understood what you are reporting, your title is misleading.

GroupName will not affect other windows. I agree that there's a bug somewhere, but I'm not sure its about GroupName, it might also be about bindings.

Another option to work around is adding a GC. Collect ; somewhere e. Because the closed windows get collected and this disconnects the binding. You are right the bug is in RadioButton. It doesn't need closed windows to trigger either, any window or other control currently not connected to a visual root will trigger the bug. As such GC. Collect ; doesn't always help as someone may hold disconnected UI elements in a cache.

If such disconnected UI elements contain grouped radio buttons they'll also trigger the bug, it doesn't need a Window, its just convenient for reproduction.

I'd summarize it as this: All disconnected UI elements share the same radio button group scope, which leads to bugs when disconnected UI is still connected via bindings. Closed windows act as disconnected UI, but they are not the only case. The point of the bug report is that everything not attached to a visual root will start sharing their radiobutton groups.

If the radiobuttons were databound this will lead to a feedback loop. To specify the image to be displayed I would require some way of specifying which image. I started thinking and decided it would be better to put all the information required for displaying each item in the XAML and not try to depend on the ViewModel for any of this information, and then just have a way to pass the needed information from the selected RadioButton to the ViewModel using Binding.

If a GroupName is specified meaning GroupName is not null nor empty , then this collection is filtered for all RadioButton controls that have that GroupName. For each of these RadioButton controls, its Checked event is subscribed to so that the control knows when one of its RadioButton controls is selected.



0コメント

  • 1000 / 1000