I'm using x:Bind with mode=OneWay.
<CommandBar
DefaultLabelPosition="Bottom"
RelativePanel.RightOf="AutoSuggestBoxSearchItem">
<AppBarButton
x:Name="DetailsButton"
Icon="Contact"
Label="View details"
IsEnabled="{x:Bind converters:Converters.IsNotNull(ViewModel.SelectedItem), Mode=OneWay}"/>
<AppBarButton
x:Name="DeleteButton"
Icon="Delete"
Label="Delete"
IsEnabled="{x:Bind converters:Converters.IsNotNull(ViewModel.SelectedItem), Mode=OneWay}"/>
<AppBarSeparator/>
<AppBarButton
x:Name="AddButton"
Icon="Add"
Label="Add"/>
IsNotNull check's if object is not null.
public class Converters
{
public static bool IsNotNull(object value) => value != null;
}
ViewModel.SectedItem show's selected item in datagrid. So when i select item in DataGrid, app bar buttons must set property isEnabled to true.
But: 2 first button on the top must be available, but thay aren't
Create a property and bind it to IsEnabled as shown below IsEnabled="{x:Bind propertyName)
On the property setter use OnPropertyChanged("propertyName")