Problème de Bind DataTemplate
Salut à tous!
Alors j'ai une liste d'objets de type MonTypeItem que je bind à une GridView
J'ai 2 Templates :
- une CheckBox sur laquelle j'ai un IsChecked Bindé (ça ça marche)
- une UC avec une propriété de type MonType > ça ça ne marche pas
Code:
1 2 3 4 5 6
|
public class MonTypeItem
{
public MonType PropType { get; set; }
public bool Active { get; set; }
} |
Voilà la partie de l'uc interessante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#region Dependency properties
public MonType MaProp
{
get { return (MonType)GetValue(MaPropProperty); }
set { SetValue(MaPropProperty, value); }
}
public static readonly DependencyProperty MaPropProperty = DependencyProperty.Register("MaProp", typeof(MonType), typeof(UC),new FrameworkPropertyMetadata(OnMaPropChanged));
private static void OnMaPropChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
//CODE
} |
Voici le code XAML :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<DataTemplate x:Key="tpl1">
<StackPanel>
<CheckBox IsChecked="{Binding Path=Active}" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="tpl2">
<StackPanel>
<c:UC MaProp="{Binding Path=PropType}" DataContextChanged="UC_DataContextChanged" />
</StackPanel>
</DataTemplate>
(...)
<ListView.View>
<GridView x:Name="gv">
<GridViewColumn CellTemplate="{StaticResource tpl1}" />
<GridViewColumn CellTemplate="{StaticResource tpl2}" />
</GridView>
</ListView.View> |
J'ai mis l'evenement DataContextChanged mais je ne récupère rien.. J'imagine que le problème est lié à ça.. Mais alors pourquoi le bind fonctionne bien avec la check box??
Merci d'avance