Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Custom Dependency Property and Binding

 
 
Old 01-10-2006   #1 (permalink)
CSkinner


 
 

Custom Dependency Property and Binding

I cannot get databinding to work with a custom property. I've simplified the
situation in the following code. I'm trying to keep the currently selected
item in a treeview in synch with the data being displayed in a custom
control. The control in this case simply wraps a TextBlock for example
purposes. I've include the xaml and code behind file. I'm simply using the
control like this:

<t:TestObject Grid.Row="1" Text2="{Binding ElementName=mProjectTree,
Path=SelectedValue.Description}" />

Please understand that if I use a normal TextBlock with the binding
expression above, all works fine. I'm simply not doing something right in
regards to setting up the DependencyObject. No runtime errors, I'm just not
seeing the internal TextBlock's Text property being set ( so I never see the
dependencypropertychanged event fire ). If I set the Text2 property
manually, I do see the DependencyPropertyChanged event fire, so my break
point in the OnChanged method on TestObject fires. But not in the data
binding case.

Thanks for any help,

CS







My System SpecsSystem Spec
Old 01-10-2006   #2 (permalink)
auto239436@hushmail.com


 
 

Re: Custom Dependency Property and Binding

Can you post again without the encoded source?

My System SpecsSystem Spec
Old 01-10-2006   #3 (permalink)
Nick Kramer [MSFT]


 
 

Re: Custom Dependency Property and Binding

Does the debug output tell you anything useful? Data binding sends many
nice messages to the debug output stream...

-Nick Kramer [MSFT]
http://blogs.msdn.com/nickkramer

---
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"CSkinner" <cwskinner_no_sppaaam@comcast.net> wrote in message
news:%23$BuCn1AGHA.1216@TK2MSFTNGP14.phx.gbl...
>I cannot get databinding to work with a custom property. I've simplified
>the situation in the following code. I'm trying to keep the currently
>selected item in a treeview in synch with the data being displayed in a
>custom control. The control in this case simply wraps a TextBlock for
>example purposes. I've include the xaml and code behind file. I'm simply
>using the control like this:
>
> <t:TestObject Grid.Row="1" Text2="{Binding ElementName=mProjectTree,
> Path=SelectedValue.Description}" />
>
> Please understand that if I use a normal TextBlock with the binding
> expression above, all works fine. I'm simply not doing something right in
> regards to setting up the DependencyObject. No runtime errors, I'm just
> not seeing the internal TextBlock's Text property being set ( so I never
> see the dependencypropertychanged event fire ). If I set the Text2
> property manually, I do see the DependencyPropertyChanged event fire, so
> my break point in the OnChanged method on TestObject fires. But not in the
> data binding case.
>
> Thanks for any help,
>
> CS
>
>
>



My System SpecsSystem Spec
Old 01-10-2006   #4 (permalink)
CSkinner


 
 

Re: Custom Dependency Property and Binding

Nothing indicating what could be the problem...


"Nick Kramer [MSFT]" <nkramer@ms.spam> wrote in message
news:etykPfcBGHA.1088@tk2msftngp13.phx.gbl...
> Does the debug output tell you anything useful? Data binding sends many
> nice messages to the debug output stream...
>
> -Nick Kramer [MSFT]
> http://blogs.msdn.com/nickkramer
>
> ---
> This posting is provided "AS IS" with no warranties, and confers no
> rights. Use of included script samples are subject to the terms specified
> at http://www.microsoft.com/info/cpyright.htm
>
>
> "CSkinner" <cwskinner_no_sppaaam@comcast.net> wrote in message
> news:%23$BuCn1AGHA.1216@TK2MSFTNGP14.phx.gbl...
>>I cannot get databinding to work with a custom property. I've simplified
>>the situation in the following code. I'm trying to keep the currently
>>selected item in a treeview in synch with the data being displayed in a
>>custom control. The control in this case simply wraps a TextBlock for
>>example purposes. I've include the xaml and code behind file. I'm simply
>>using the control like this:
>>
>> <t:TestObject Grid.Row="1" Text2="{Binding ElementName=mProjectTree,
>> Path=SelectedValue.Description}" />
>>
>> Please understand that if I use a normal TextBlock with the binding
>> expression above, all works fine. I'm simply not doing something right in
>> regards to setting up the DependencyObject. No runtime errors, I'm just
>> not seeing the internal TextBlock's Text property being set ( so I never
>> see the dependencypropertychanged event fire ). If I set the Text2
>> property manually, I do see the DependencyPropertyChanged event fire, so
>> my break point in the OnChanged method on TestObject fires. But not in
>> the data binding case.
>>
>> Thanks for any help,
>>
>> CS
>>
>>
>>

>
>



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
WPF: Autogenerate a Private Dependency Property ? .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46