Skip to main content

Microsoft Silverlight

Answered Question databind to an attched propertyRSS Feed

(0)

davesmits
davesmits

Member

Member

624 points

198 Posts

databind to an attched property

how can i databind to an attched property in xaml? when using {binding something} it only looks to his datacontext

jay nanavati
jay nana...

Contributor

Contributor

3388 points

624 Posts

Re: databind to an attched property

 Read this thread:

http://silverlight.net/forums/t/21814.aspx

Jay K Nanavaty
www.technologyopinion.com
Mark as answer if it helps. It will also help others...

davesmits
davesmits

Member

Member

624 points

198 Posts

Re: databind to an attched property

Thank you for you reply but unfortunaly i think it not my problem;

 Ik have a custom user control; and in that user control i made an attached property.

public bool AllowNewExits

{

get { return (bool)GetValue(ExitListControl.AllowNewExitsProperty); }set { SetValue(ExitListControl.AllowNewExitsProperty, value);

} 

in the same user control i want to databind to this property

Amanda Wang - MSFT
Amanda W...

All-Star

All-Star

17241 points

1,466 Posts

Answered Question

Re: databind to an attched property

 Hi davesmits ,

Below is a sample code to implement to make the button's content proeprty bind to the attached property, it works fine in our labs.

1. The  xaml code of the button:

 <Button x:Name="bouton"  Content="{Binding}"   Click="bouton_Click"></Button>

2. the codebehind(the btn is a publicj in the SilverlightControl2 ):

  SilverlightControl2 ctl = new SilverlightControl2();
this.bouton.DataContext = ctl.btn;

 

Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities