Есть левая и правая кнопки, центральный label. 
                  
                  
                  По Label все понятно:
                  
                  
                  1. Назначаю  биндинг          
                  
                  
                  centerLabel.SetBinding(Label.TextProperty, new TemplateBinding("Parent.BindingContext.HeaderText"));
                  
                  
                  
                  
                  
                  2. Реализую на странице
                  
                  
                  ...
                  
                  
                   public static readonly BindableProperty HeaderTextProperty = BindableProperty.Create(
                  
                  
                              nameof(HeaderText),
                  
                  
                              typeof(string),
                  
                  
                              typeof(ProfilePage),
                  
                  
                              string.Empty,
                  
                  
                              BindingMode.TwoWay);
                  
                  
                  
                  
                  
                          public string HeaderText
                  
                  
                          {
                  
                  
                              get => (string)GetValue(HeaderTextProperty);
                  
                  
                              set => SetValue(HeaderTextProperty, value);
                  
                  
                          }
                  
                  
                  
                  
                  
                  ...
                  
                  
                  this.SetBinding(HeaderTextProperty, "HeaderText");
                  
                  
                  ...
                  
                  
                  
                  
                  
                  3. Определяю во ViewModel 
                  
                  
                  public string HeaderText => "Профиль";
                  
                  
                  
                  
                  
                  Все работает. А как тоже самое сделать с Button.ImageProperty кнопок? 
                  
                  
                  1. Назначаю  биндинг          
                  
                  
                  rightButton.SetBinding(Button.ImageProperty, new TemplateBinding("Parent.BindingContext.RightButtonImage"));
                  
                  
                  
                  
                  
                  2. Реализую на странице
                  
                  
                  ...
                  
                  
                          public static readonly BindableProperty RightButtonImageProperty = BindableProperty.Create(
                  
                  
                              nameof(RightButtonImage),
                  
                  
                              typeof(string),
                  
                  
                              typeof(ProfilePage),
                  
                  
                              "",
                  
                  
                              BindingMode.TwoWay);
                  
                  
                  
                  
                  
                          public string RightButtonImage
                  
                  
                          {
                  
                  
                              get => base.GetValue(RightButtonImageProperty).ToString();
                  
                  
                              set => base.SetValue(RightButtonImageProperty, value);
                  
                  
                          }
                  
                  
                  
                  
                  
                  ...
                  
                  
                  this.SetBinding(RightButtonImageProperty, "RightButtonImage");
                  
                  
                  ...
                  
                  
                  
                  
                  
                  3. Определяю во ViewModel 
                  
                  
                  public string RightButtonImage = "icons/icon_settings.png";
                  
                  
                  
                  
                  
                  Но ничего не получается. Что  не так делаю?
                  
                  
                
ios/android? И попробуй RightButtonImagePropert сделать FileImageSource, а не string
Обсуждают сегодня