Search code examples
windowswinrt-xamldevexpress-windows-ui

How to add label to Checkbox in Windows::UI::XAML::Controls


I am new to WINDOWS UI. Trying my hands with XAML based programming through C++.

Here is the dummy piece of code that I am trying.

Stackpanel st;
CheckBox checkBox;
checkBox.Name() = L"";
st().Children().Append(checkBox);

How can we add label to check box?


Solution

  • It seems that you are using C++/WinRT and you are trying to set the content of the CheckBox control. Please try the following code:

      CheckBox checkBox;
        checkBox.Name(L"");
        checkBox.Content(winrt::box_value(L"Check Tag"));
        st().Children().Append(checkBox);
    

    Check Tag should be the content that you want to add.