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

37 Views Asked by At

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?

1

There are 1 best solutions below

3
Roy Li - MSFT On BEST ANSWER

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.