Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have reproduced your problem. But everything works fine.</p> <p>The problem may be that the <code>GroupName</code> property of the radio button is not defined. Give a same name for the GroupName of the two radio buttons.</p> <p>Ex:</p> <pre><code>&lt;RadioButton Content="No" GroupName="group1" /&gt; &lt;RadioButton Content="Yes" GroupName="group1" /&gt; </code></pre> <p>This is my full XAML:</p> <pre><code>&lt;Window x:Class="RadioButtonFocus.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" Title="MainWindow" Height="350" Width="525"&gt; &lt;Grid Name="mainGrid"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;RadioButton Content="No" GroupName="group1" IsChecked="{Binding IsNoChecked}"&gt; &lt;i:Interaction.Triggers&gt; &lt;i:EventTrigger EventName="MouseEnter"&gt; &lt;i:InvokeCommandAction Command="{Binding CheckNoCommand}" /&gt; &lt;/i:EventTrigger&gt; &lt;/i:Interaction.Triggers&gt; &lt;/RadioButton&gt; &lt;RadioButton Content="Yes" GroupName="group1" IsChecked="{Binding IsYesChecked}"&gt; &lt;i:Interaction.Triggers&gt; &lt;i:EventTrigger EventName="MouseEnter"&gt; &lt;i:InvokeCommandAction Command="{Binding CheckYesCommand}" /&gt; &lt;/i:EventTrigger&gt; &lt;/i:Interaction.Triggers&gt; &lt;/RadioButton&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>ViewModel</p> <pre class="lang-cs prettyprint-override"><code>public class MainViewModel : ViewModelBase { #region Declarations private bool isNoChecked; private bool isYesChecked; private ICommand checkNoCommand; private ICommand checkYesCommand; #endregion #region Properties /// &lt;summary&gt; /// Gets or sets a value indicating whether this instance is no checked. /// &lt;/summary&gt; /// &lt;value&gt; /// &lt;c&gt;true&lt;/c&gt; if this instance is no checked; otherwise, &lt;c&gt;false&lt;/c&gt;. /// &lt;/value&gt; public bool IsNoChecked { get { return isNoChecked; } set { isNoChecked = value; NotifyPropertyChanged("IsNoChecked"); } } /// &lt;summary&gt; /// Gets or sets a value indicating whether this instance is yes checked. /// &lt;/summary&gt; /// &lt;value&gt; /// &lt;c&gt;true&lt;/c&gt; if this instance is yes checked; otherwise, &lt;c&gt;false&lt;/c&gt;. /// &lt;/value&gt; public bool IsYesChecked { get { return isYesChecked; } set { isYesChecked = value; NotifyPropertyChanged("IsYesChecked"); } } #endregion #region Commands /// &lt;summary&gt; /// Gets the check no command. /// &lt;/summary&gt; /// &lt;value&gt;The check no command.&lt;/value&gt; public ICommand CheckNoCommand { get { if (checkNoCommand == null) { checkNoCommand = new RelayCommand(param =&gt; this.CheckNo(), null); } return checkNoCommand; } } /// &lt;summary&gt; /// Gets the check yes command. /// &lt;/summary&gt; /// &lt;value&gt;The check yes command.&lt;/value&gt; public ICommand CheckYesCommand { get { if (checkYesCommand == null) { checkYesCommand = new RelayCommand(param =&gt; this.CheckYes(), null); } return checkYesCommand; } } #endregion #region Private Methods /// &lt;summary&gt; /// Changes the checked. /// &lt;/summary&gt; private void CheckNo() { this.IsNoChecked = true; } /// &lt;summary&gt; /// Checks the yes. /// &lt;/summary&gt; private void CheckYes() { this.IsYesChecked = true; } #endregion } </code></pre> <p>NOTE: Here I have used Interactivity library. You have to install a redistributable to work this example. You can download it from <a href="http://www.microsoft.com/en-us/download/details.aspx?id=10801" rel="nofollow">here</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload