I have a WPF control (ControlA) which references another control (ControlB) like so:
<Grid>
<controls:ControlB x:Name="ControlB" />
<my:DataGrid
x:Name="dataGridBackup"
ItemsSource="{Binding}"
AutoGenerateColumns="False" >
<my:DataGrid.Columns>
<my:DataGridCheckBoxColumn
Header="Connectable"
Binding="{Binding Connectable}" />
</my:DataGrid.Columns>
</my:DataGrid>
</Grid>
Now in ControlB I have a button and i want to bind the IsEnabled property to the Connectable column of my Grid on controlA.
I can get it working when i have the controls on the same page but not in the aboce scenario. I tried with
<Button
IsEnabled="{Binding ElementName=dataGridBackup, Path=SelectedItem.Connectable}">
</Button>
Button inside
ControlBhas no normal way to know what’s outside the controlControlB. One possible solution is to add boolean dependency property toControlBlikeIsConnectable. In XAML of controlControlA, bind the property todataGridBackupwith path, like you did. In XAML of controlControlB, bind the button’sIsEnabledproperty toIsConnectableofControlB.