Bonjour
J'ai 2 entités comme suit :
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 [MetadataTypeAttribute(typeof(Poste.PosteMetadata))] public partial class Poste { internal sealed class PosteMetadata { private PosteMetadata() { } public int ID { get; set; } public string Intitule { get; set; } public EntityCollection<Salarie> Salarie { get; set; } } } [MetadataTypeAttribute(typeof(Salarie.SalarieMetadata))] public partial class Salarie { internal sealed class SalarieMetadata { private SalarieMetadata() { } public int ID { get; set; } public string Nom { get; set; } [Include] public Poste Poste { get; set; } public int? Poste_ID { get; set; } } }
En gros un Poste peut avoir plusieurs Salariés, et un Salariés peut avoir 0 ou 1 Poste.
J'ai donc pour matérialisé la relation un int? dans Salarie pour mémoriser l'ID du Poste.
J'ai de l'autre coté un formulaire Silverlight où je souhaite avoir un menu déroulant (Combobox) pour sélectionner un des postes présent dans ma base.
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <toolkit:DataField PropertyPath="Poste"> <ComboBox Height="23" ItemsSource="{Binding Path=Data, Source={StaticResource posteDomainDataSource}}" Name="posteComboBox" Width="120" DisplayMemberPath="Intitule" SelectedValuePath="ID" SelectedValue="{Binding Poste_ID, Mode=TwoWay}"> <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </ComboBox.ItemsPanel> </ComboBox> </toolkit:DataField>
Cela fonctionne bien, sauf qu'une fois le poste attribuer, je ne peut plus remettre cette valeur à null.
Mon DomainDataSource charge la liste des Postes présent dans la DataBase comme suis:
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Poste, CreateList=true}" LoadedData="posteDomainDataSource_LoadedData" x:Key="posteDomainDataSource" QueryName="GetPosteJeuQuery"> <riaControls:DomainDataSource.DomainContext> <my:DomainServicePerso /> </riaControls:DomainDataSource.DomainContext> </riaControls:DomainDataSource>
Comment puis-je faire pour permettre a l'utilisateur de remettre ce champ vide une fois remplis?
Partager