I am creating an AppBarButton in code behind file of XAML view. Currently, I have AppBarButton defined in XAML as below:
<AppBarButton x:Name="SelectVisitAppBarButton" x:Uid="AppBar_TransferVisit" Margin="0,0,12,0" Icon="Bullets" Style="{StaticResource TransferAppBarButtonStyle}" IsEnabled="{Binding ScheduleViewVm.IsVisitSelectionEnable}" Click="SelectVisit_Click" />
I want to convert this XAML into C# code. Following is the code that I have till now.
AppBarButton SelectVisitAppBarButton = new AppBarButton();
SelectVisitAppBarButton.Margin = new Thickness(0, 0, 12, 0);
SymbolIcon bulletSymbol = new SymbolIcon();
bulletSymbol.Symbol = Symbol.Bullets;
SelectVisitAppBarButton.Icon = bulletSymbol;
SelectVisitAppBarButton.Style = App.Current.Resources["TransferAppBarButtonStyle"] as Style;
SelectVisitAppBarButton.Click += SelectVisit_Click;
Binding b = new Binding();
b.Source = _viewModel.ScheduleViewVm.IsVisitSelectionEnable;
SelectVisitAppBarButton.SetBinding(Control.IsEnabledProperty, b);
Appbar.Children.Add(SelectVisitAppBarButton);
The only thing I am looking for is to convert x:Uid="AppBar_TransferVisit" into its equivalent C# code. Any help on this is highly appreciated.
Thanks, Naresh Ravlani.