Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

DependencyProperty on UserControl - PropertyChangedCallback not firing on binding

$
0
0

Hi,

After finishing my AutoCompleteSearchBox UserControl, I now attempt to make it reusable. Therefore, I need to expose some dependency properties such asIList<object> SearchSource and string SearchSourceType.

This is the UserControl:

 public partial class SearchBox : UserControl
    {

public string SearchSourceType { get { return (string)GetValue(SearchSourceTypeProperty); } set { SetValue(SearchSourceTypeProperty, value); } } public static readonly DependencyProperty SearchSourceTypeProperty = DependencyProperty.Register("SearchSourceType", typeof(string), typeof(SearchBox), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, new PropertyChangedCallback(OnPropertyChanged)));

And this is how I use it in another window:

<sb:SearchBox SearchSourceType="{Binding SearchSourceType}"/>

The problem is, OnPropertyChanged never gets called. When I replace the binding with a simple string, it is called just fine. I tried binding it to a different element that I can see to make sure the binding is fine.

Something that might be important to note...the binding is done from a UserControl that is bound to his ViewModel by DataTemplate.

Any help would be apreaciated!


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>