I am here with a new problem.
I have a DataGrid and a TextBox. I would like to filter the DataGrid based on the TextBox's value.
I have done that using MarkupExtensions as mentioned here.
Now it works fine upto the Value property (Property of PropertyFilter class as mentioned in above link) is a string mentioned in XAML. When I change it to binding it stops working. Here is my XAML with binding:
<CollectionViewSource x:Key="GroupsViewSource" Source="{Binding Groups}">
    <CollectionViewSource.Filter>
        <me:Filter>
            <me:PropertyFilter PropertyName="GroupName"
                               Value="{Binding SearchGroupName}" />
        </me:Filter>
    </CollectionViewSource.Filter>
</CollectionViewSource>
SearchGroupName is a simple Property of type string in my ViewModel.
I have also tried to change the binding as follows:
Value = "{Binding DataContext.SearchGroupName, RelativeSource={RelativeSource 
                               Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
I have tried to debug it using System.Diagnostics as follows:
<CollectionViewSource x:Key="GroupsViewSource" Source="{Binding Groups}">
    <CollectionViewSource.Filter>
        <me:Filter>
            <me:PropertyFilter PropertyName="GroupName"
                               Value="{Binding SearchGroupName, diag:PresentationTraceSources.TraceLevel=High}" />
        </me:Filter>
    </CollectionViewSource.Filter>
</CollectionViewSource>
But then I get a compilation error : unknown property PresentationTraceSources.TraceLevel for System.Windows.Data.Binding......
I think my binding with RelativeSource does not work because I think that CollectionViewSource is not a member of Visual/Logical Tree.
Thus I think my DataContext might be null. What are the solutions that you guys prefer if you are in the same situation?????