I'm trying to bind Visibility to ToggleButton::IsChecked
using automatic IReference to Visibility conversion
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<CheckBox x:Name="myButton" Content="Click Me" />
<TextBlock Text="Hello" Visibility="{x:Bind myButton.IsChecked, Mode=OneWay}"/>
</StackPanel>
In a blank project this works. In my existing project it will work if I provide my own converter, but if I try to use auto conversion, I get:
error C3779: 'winrt::impl::consume_Windows_Foundation_IReference<
winrt::Windows::Foundation::IReference<bool>,T>::Value':
a function that returns 'auto' cannot be used before it is defined
with [ T=bool ] (compiling source file Generated Files\XamlTypeInfo.g.cpp)
If you compile for c++17 the error goes away. I was compiling for c++20
https://github.com/microsoft/microsoft-ui-xaml/issues/9214
You can get it to work in c++20 if you force the instantiation of winrt::Windows::Foundation::IReference<bool>::Value
inline void force_instantiation_of_IRefBoolValue()
{
&winrt::Windows::Foundation::IReference<bool>::Value;
}