CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Posts
    2

    Unhappy user control - binding order problem ?

    Hi,
    I want to create a user telephone control in WPF.

    I have tried many things but I can't seem to be able to pass a boolean dependency property. I think the problem has to do with the order in which the binding is processed.

    Here is what I have:

    user control telephone.xaml:
    <telerik:RadMaskedTextBox
    Name="mtbPhone"
    MaskType="Standard"
    ..
    Mask="{Binding ElementName=TelephoneControl, Path=PhoneMask}"
    />


    user control telephone.xaml.vb:
    Public Shared ReadOnly HasExtensionProperty As DependencyProperty = DependencyProperty.Register("HasExtension", GetType(Boolean), GetType(Telephone))
    Public Property HasExtension() As Boolean
    Get
    Return CType(GetValue(HasExtensionProperty), Boolean)
    End Get
    Set(ByVal value As Boolean)
    SetValue(HasExtensionProperty, value)
    End Set
    End Property
    ----
    Public ReadOnly Property PhoneMask() As String

    Get
    If HasExtension() = True Then 'mask depends on dependency property
    Return "(999) 999-9999 Ext:.9999"
    Else
    Return "(999) 999-9999"
    End If

    End Get

    End Property

    =======================
    here is the xaml of a page that uses the telephone control
    <customcontrols:Telephone Name="tlpMainTelephone"
    ...
    HasExtension="True"

    />

    =======================

    When I debug, in the "PhoneMask" property of "telephone.xaml.vb" the HasExtension() statement always "False".

    If HasExtension() = True Then 'HasExtension is always False !!!

    Why am I getting False !!! I pass "True" in my calling page ?
    <customcontrols:Telephone Name="tlpMainTelephone"
    ...
    HasExtension="True"




    Thanks in advance

  2. #2
    Join Date
    Mar 2011
    Posts
    2

    Re: user control - binding order problem ?

    anyone care to show me the so called "power of binding" ....

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: user control - binding order problem ?

    I'd like to help but I'm only good for C#. It might help if you zipped up a small sample project that repros the problem and attach it here.

    That way folks could modify it and maybe solve your problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured