I have my own control and the binding does not work in it. Below is the code that I tried to bind.
The code in XAML
<cc:MyControl Name="myControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemSource="{Binding Path=Document}"></cc:MyControl>
The code in CodeBehind for ItemSource Dependency Property
public Object ItemSource
{
get { return (Object)GetValue(ItemSourceProperty); }
set { SetValue(ItemSourceProperty, value); }
}
public static readonly DependencyProperty ItemSourceProperty =
DependencyProperty.Register("ItemSource", typeof(Object), typeof(MyControl), new PropertyMetadata(null, new PropertyChangedCallback(DocumentLoadCallBack)));
private static void DocumentLoadCallBack(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
}
This does not gets even triggered.....
But When I provide ItemSource with some data without binding as below, the DocumentLoadCallBack gets triggered.
<cc:MyControl Name="myControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemSource="ImagePath"></cc:MyControl>
The "Document" bind property code
public sealed partial class MainPage : Page
{
private StorageFile _doc = null;
public StorageFile Document
{
get
{
if (this._doc == null)
{
this._doc = GetDoc().Result;
}
return this._doc;
}
set
{
this._doc = value;
}
}
private async Task<StorageFile> GetDoc()
{
//return imagedocument location
}
}
Anyone, help me out on this?