Here's a minimal example of data binding. I would like know how to factor out both the ToggleSwitch and Button into different UserControls while keeping the data binding.
//MainWindow.xaml
<StackPanel>
<ToggleSwitch x:Name="MyToggle" OffContent="Off" OnContent="On"/>
<Button IsEnabled="{x:Bind MyToggle.IsOn, Mode=OneWay}" Content="Click Me"/>
</StackPanel>
// MainWindow.idl
Microsoft.UI.Xaml.Controls.ToggleSwitch MyToggle{ get; };
Publically expose MyToggleControl and MyToggle so
"{x:Bind MyToggleControl.MyToggle.IsOn}"is available. Then createIsButtonEnabledproperty so thatIsButtonEnabled="{x:Bind ...}"will work.Expose the
UserControlToggleas a public property ofMainWindowExpose the
ToggleSwitchas a public property ofUserControlToggleWrap the buttons
IsEnabledproperty to a property onUserControlButton