locked
Dependency Property issue RRS feed

  • Question

  • Hi,
     I have a UserControl which has a Dependency Property which i am binding with a property on my ViewModel.The First time i change my ViewModel property the DependencyProperty of the usercontrl gets updated but not after that..I have defined the Dependency property as folows..Am i missing anything here?

      public static readonly DependencyProperty myDepProperty =
    DependencyProperty.Register("myDep", typeof(List<string>), typeof(GroupGridControl),
                new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender,
    new PropertyChangedCallback(OnmyDepChanged)));

    and my xaml code has the following

    <UC:MyUserControl  x:Name="mtCtrl" myDep="{Binding Path=ViewModelPropert}" >
                            </UC:GroupGridControl>

    I was hoping that everytime i change my viewModel Property value in code,it will cause the "OnmyDepChanged" callback to get executed.. Please advice..

    thanks in advance..
    Tuesday, February 2, 2010 9:59 PM

Answers

  • Try using

    <UC:MyUserControl  x:Name="mtCtrl" myDep="{Binding Path=ViewModelPropert, UpdateSourceTrigger=PropertyChanged}" >
    
    If you need two way binding ( I don't really understand your issue, but I assume you do) you got to Bind like this:

    <UC:MyUserControl  x:Name="mtCtrl" myDep="{Binding Path=ViewModelProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
              
    
    • Marked as answer by Zest4Quest Thursday, February 4, 2010 5:36 PM
    Tuesday, February 2, 2010 11:15 PM