0

I have one UserControl nested inside the other UserControl, something like that:

<uc:MyControl1>
  <uc:MyControl2 Name="cheese"/>
</uc:MyControl2>

uc:MyControl2 contains a DP Name. And inside uc:MyControl1 I am exposing uc:MyControl2 using a standard property:

   public uc:MyControl1 ExposedMyProperty1 {get{return MyProperty1}}

But I still can't access it form the uc:MyControl1 :

<uc:MyControl1 ExposedMyProperty1.Name="Milk">
  <uc:MyControl2/>
</uc:MyControl2>

Intellisense shows only the properties of the UserControl, but not of my derived version of the UserControl. Meaning I see all the properties which comes from the UserControl, but don't see DP I have defined. So it looks like I am getting a UserControl instead of uc:MyControl1.

Am I missing something here?

2 Answers 2

1

In your code sample you only expose a getter and not a setter. That may be your problem.

Try this:

public string ExposedMyProperty1 { get {return MyProperty1; } set {MyProperty1 = value;}}

But your code sample appears to be incomplete. For you say you are exposing a DependencyProperty, and your property is only a regular property. So this may not be the solution to your problem.

Sign up to request clarification or add additional context in comments.

3 Comments

I am exposing a DP of uc:MyControl2 using a standart property. Adding setter doesn't help (tried already).
@Vitalij: What error do you get? And can you update your code sample to be more complete?
I am sorry! I have missed two very important points and without them a question doesn't make much sense. I have just updated my question.
0

I have found an answer to my question. The answer is: you can't access nested properties from you xaml. I don't know what is the reason for WPF not allowing that..

The answer comes from this post

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.