Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Is it possible to build a MasterDetailPage Custom Control with Bindable Detail property

$
0
0

I am still struggling to get my head around custom controls. Although I must say I havent designed many custom controls in c#. So far I have:

public class MasterDetailPage : Xamarin.Forms.MasterDetailPage
{
    public static BindableProperty DetailProperty = BindableProperty.Create("DetailPageKey", typeof(string), typeof(MasterDetailPage), ViewModelLocator.DashBoardPage, BindingMode.TwoWay, null, null, null, null);

     public MasterDetailPage()
     {
         if (this.Detail == null && DetailPageKey != null)
         {
             this.Detail = SimpleIoc.Default.GetInstance<IPageOperations>().InitialiseDetailPage((string)this.GetValue(DetailProperty));
             this.Title = (this.Detail as Page).Title;
         }
     }

    public string DetailPageKey
    {
        get 
        {

            return (string)this.GetValue(DetailProperty);
        }
        set 
        { 
            this.SetValue(DetailProperty, value);
            this.Detail = SimpleIoc.Default.GetInstance<IPageOperations>().InitialiseDetailPage((string)this.GetValue(DetailProperty));
        }
    }

At the moment I am Navigating and initializing pages through my IPageOperations interface. But where am I going wrong? I would expect it to work so that I could do DetailPageKey="{Binding myprop)" and it would work but currently it doesnt :(. It should be possible with little effort


Viewing all articles
Browse latest Browse all 58056

Trending Articles