Reputation: 3515
I want to use dependency property which will represent ICarRepository
instance.
So I've found this post and based on acc. answer I tried with my example
public static readonly DependencyProperty RepositoryProperty = DependencyProperty.Register(
null,
typeof(ICarRepository ),
typeof(TreassureControl),
**new PropertyMetadata(??????)** what to put here?
);
public ICarRepository Repository
{
get { return (ICarRepository)GetValue(RepositoryProperty); }
set { SetValue(RepositoryProperty, value); }
}
Upvotes: 0
Views: 1171
Reputation: 81253
PropertyIdentifier
cannot be null (first parameter), pass CLR wrapper property name in it which is Repository
.
Regarding PropertyMetadata
, you can set that to null
. Also you can use other overload where you don't need to pass that value.
public static readonly DependencyProperty RepositoryProperty =
DependencyProperty.Register(
"Repository",
typeof(ICarRepository ),
typeof(TreassureControl),
new PropertyMetadata(null));
OR simply avoid last parameter:
public static readonly DependencyProperty RepositoryProperty =
DependencyProperty.Register(
"Repository",
typeof(ICarRepository ),
typeof(TreassureControl));
Upvotes: 2