Q:

UWP: Cannot access menu Checkbox from Code-Behind

I've created a menu with 3 Checkboxes in it: "menuRefreshFast", "menuRefreshMedium", and "menuRefreshSlow".
          <controls:MenuItem Header="UI" FontFamily="Microsoft Sans Serif" TabIndex="103">
                <CheckBox x:Name="menuRefreshFast" Content="Fast"></CheckBox>
                <MenuFlyoutSubItem x:Name="menuRefresh" Text="Refresh Rate">
                    <MenuFlyoutItem>
                        <MenuFlyoutItem.Template>
                            <ControlTemplate TargetType="MenuFlyoutItem">
                                <CheckBox x:Name="menuRefreshFast" Content="Fast (250ms)" Click="menuRefreshFast_Click" Tag="menuRefreshFast"/>
                            </ControlTemplate>
                        </MenuFlyoutItem.Template>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem>
                        <MenuFlyoutItem.Template>
                            <ControlTemplate TargetType="MenuFlyoutItem">
                                <CheckBox x:Name="menuRefreshMedium" Content="Medium (500ms)" Click="menuRefreshMedium_Click" Tag="menuRefreshMedium"/>
                            </ControlTemplate>
                        </MenuFlyoutItem.Template>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem>
                        <MenuFlyoutItem.Template>
                            <ControlTemplate TargetType="MenuFlyoutItem">
                                <CheckBox x:Name="menuRefreshSlow" Content="Slow (1s)" Click="menuRefreshSlow_Click" Tag="menuRefreshSlow"/>
                            </ControlTemplate>
                        </MenuFlyoutItem.Template>
                    </MenuFlyoutItem>
                </MenuFlyoutSubItem>
            </controls:MenuItem>

When I load the app I can see the GUI doing the right thing. However when I try to reference these Checkboxes using the x:Name, it doesn't recognize them! Can someone explain to me why?
screenshot: Code-behind doesn't recognize the Checkboxes

A:

You can not access the control in the XAML ControlTemplate from the page code behind using the control's name directly. The ControlTemplate defines the element tree that is used as the control template for a control, its children elements don't exposed to your page to make you access it from page's code behind. Generally, we use the VisualTreeHelper Class, you can find more info about it from internet. You can also use the way from @Dishant to get the CheckBox in your this case.
But if you want to make the selected items mutually exclusive, I will suggest you to use the Radio buttons, you can group the Radio buttons to make users can only select one radio button in a radio button group. See the Create a radio button part to make Radio buttons work in groups.
Here is the example code base on your code above.
        <controls:Menu>
            <controls:MenuItem Header="UI" FontFamily="Microsoft Sans Serif" TabIndex="103">
                <CheckBox x:Name="menuRefreshFast" Content="Fast"></CheckBox>
                <MenuFlyoutSubItem x:Name="menuRefresh" Text="Refresh Rate">
                    <MenuFlyoutItem>
                        <MenuFlyoutItem.Template>
                            <ControlTemplate TargetType="MenuFlyoutItem">
                                <RadioButton x:Name="menuRefreshFast" GroupName="MyGroup" Content="Fast (250ms)" Click="menuRefreshFast_Click" Tag="menuRefreshFast"/>
                            </ControlTemplate>
                        </MenuFlyoutItem.Template>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem>
                        <MenuFlyoutItem.Template>
                            <ControlTemplate TargetType="MenuFlyoutItem">
                                <RadioButton x:Name="menuRefreshMedium"  GroupName="MyGroup" Content="Medium (500ms)" Click="menuRefreshMedium_Click" Tag="menuRefreshMedium"/>
                            </ControlTemplate>
                        </MenuFlyoutItem.Template>
                    </MenuFlyoutItem>
                    <MenuFlyoutItem>
                        <MenuFlyoutItem.Template>
                            <ControlTemplate TargetType="MenuFlyoutItem">
                                <RadioButton x:Name="menuRefreshSlow"  GroupName="MyGroup" Content="Slow (1s)" Click="menuRefreshSlow_Click" Tag="menuRefreshSlow"/>
                            </ControlTemplate>
                        </MenuFlyoutItem.Template>
                    </MenuFlyoutItem>
                </MenuFlyoutSubItem>
            </controls:MenuItem>
        </controls:Menu>

