Setting a property in XAML for a User Control

Posted by Ben on Stack Overflow See other posts from Stack Overflow or by Ben
Published on 2010-05-12T08:51:46Z Indexed on 2010/05/12 8:54 UTC
Read the original article Hit count: 213

Filed under:
|
|

Hi, I have a user control that has a property of type Integer, that i am trying to set in the XAML Template to be that of a property within the bindingsource. If I set the property using a hard coded integer i.e.

<MyControl MyIntegerProperty="3" />

This works fine, but if i try

<MyControl MyIntegerProperty="{Binding MyDataContextIntegerProperty}" />

it fails.

I know that the integer property on MyDataContext is returning a valid integer, and i know that this format works, as directly above this in the template, i have the line

 <TextBlock Text="{Binding MyDataContextStringProperty}" />

which works correctly.

Is there any flag that i need to set on my User Controls Integer property to allow this to work? Or am i doing something else wrong?

Thanks

© Stack Overflow or respective owner

Related posts about wpf

Related posts about .NET