Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I built user control with DependencyProperty like this:
C#
public string SelectedString{
    get { return (string)GetValue(SelectedClientProperty); }
    set { SetValue(SelectedClientProperty, value); InvokePropertyChanged("SelectedString"); }
}

// Using a DependencyProperty as the backing store for SelectedString.  This enables animation, styling, binding, etc...
public static readonly DependencyProperty SelectedStringProperty =
    DependencyProperty.Register("SelectedString", typeof(string), typeof(MyUserContol),
    new FrameworkPropertyMetadata(OnSelectedStringPropertyChanged));

private static void OnSelectedStringPropertyChanged(DependencyObject source,
                                                     DependencyPropertyChangedEventArgs e)
{
    (source as MyUserContol).SelectedSatringChanged();
}


and when i use it , its working good, here:
<UserContol:MyUserControl SelectedClient="blabla" />

but in dataTemplate it dosnt work! here:
XML
<DataGrid1:DataGrid x:Name="dg"   ItemsSource="{Binding MyDataTable}">
    <DataGrid1:DataGrid.Columns>
        <DataGrid1:DataGridTemplateColumn SortMemberPath="[Client]" Header="Date" >
            <DataGrid1:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <UserContol:MyUserControl SelectedClient="blabla" >
                </DataTemplate>
            </DataGrid1:DataGridTemplateColumn.CellTemplate>
    </DataGrid1:DataGrid.Columns>

</DataGrid1:DataGrid>


its not Changing the DependencyProperty to "blabla", i know it because the OnSelectedStringPropertyChanged doesnt invoke!

(its not working in listView to...)

can someone help me with this, please??
Posted
Comments
Sergey Alexandrovich Kryukov 25-Dec-11 23:04pm    
What is "Costum"?!...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900