Hello,
Reading http://docs.telerik.com/devtools/wpf/controls/raddataform/how-to/raddatafor-edit-lookup-values-with-radcombobox.html
I have a viewmodel with (simplified):
Agent
- long Id
- string FirstName
- Team Team
Team
- long Id
- string Name
In an UserControl (simplified):
<UserControl.Resources>
<viewmodels:EscortViewModel x:Key="EscortViewModel" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" DataContext="{StaticResource EscortViewModel}">
<Grid.Resources>
<DataTemplate x:Key="AgentEditTemplate">
<telerik:DataFormDataField Label="Last Name" DataMemberBinding="{Binding LastName, Mode=TwoWay}" Grid.Row="0" Grid.Column="1"/>
<telerik:DataFormComboBoxField Label="Team"
SelectedValuePath="Id"
DisplayMemberPath="Name"
Grid.Row="2" Grid.Column="1"
DataMemberBinding="{Binding Team.Id, Mode=TwoWay}"
ItemsSource="{Binding Teams, Source={StaticResource EscortViewModel}}"
/>
</Grid>
</DataTemplate>
</Grid.Resources>
<StackPanel>
<telerik:RadGridView x:Name="agentViewer"
ItemsSource="{Binding Agents}"
AutoGenerateColumns="False"
RowIndicatorVisibility="Collapsed"
IsReadOnly="True"
>
<telerik:RadGridView.Columns>
<telerik:GridViewToggleRowDetailsColumn />
<telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName, Mode=OneWay}" Header="Name" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Team.Name, Mode=OneWay}" Header="Team" />
</telerik:RadGridView.Columns>
<telerik:RadGridView.RowDetailsTemplate>
<DataTemplate>
<Grid Background="DarkGray">
<Grid Margin="15">
<telerik:RadDataForm x:Name="agentDataEdit"
CurrentItem="{Binding}"
Header="Edit agent:"
AutoGenerateFields="False"
EditTemplate="{StaticResource AgentEditTemplate}"
ReadOnlyTemplate="{StaticResource AgentEditTemplate}"
NewItemTemplate="{StaticResource AgentEditTemplate}"
>
</telerik:RadDataForm>
</Grid>
</Grid>
</DataTemplate>
</telerik:RadGridView.RowDetailsTemplate>
</telerik:RadGridView>
<Grid Background="DarkGray" x:Name="panelAddNew">
<Grid Margin="15">
<telerik:RadDataForm x:Name="agentDataNew"
Header="Add agent:"
AutoGenerateFields="False"
EditTemplate="{StaticResource AgentEditTemplate}"
ReadOnlyTemplate="{StaticResource AgentEditTemplate}"
NewItemTemplate="{StaticResource AgentEditTemplate}"
ItemsSource="{Binding Agents}"
>
</telerik:RadDataForm>
</Grid>
</Grid>
</StackPanel>
</Grid>
Almost everything works great. In the complete form, i can edit string, long and enum (with DataFormComboBoxField). What i can't do is the binding with the Agent.Team.Id.
In fact, the value from DB is displayed (team "A" or "B"...) but when i edit the form and change the Team (list displayed in the DataFormComboBoxField), it never return in the set of the Agent.Team property.
Am I missing something or did i do something wrong ? Is there a bug or an other syntax for the DataMemberBinding="{Binding Team.Id, Mode=TwoWay}" ?
I would like to not use an Agent.TeamId property but the object please.
Thank you very much.
Reading http://docs.telerik.com/devtools/wpf/controls/raddataform/how-to/raddatafor-edit-lookup-values-with-radcombobox.html
I have a viewmodel with (simplified):
Agent
- long Id
- string FirstName
- Team Team
Team
- long Id
- string Name
In an UserControl (simplified):
<UserControl.Resources>
<viewmodels:EscortViewModel x:Key="EscortViewModel" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" DataContext="{StaticResource EscortViewModel}">
<Grid.Resources>
<DataTemplate x:Key="AgentEditTemplate">
<telerik:DataFormDataField Label="Last Name" DataMemberBinding="{Binding LastName, Mode=TwoWay}" Grid.Row="0" Grid.Column="1"/>
<telerik:DataFormComboBoxField Label="Team"
SelectedValuePath="Id"
DisplayMemberPath="Name"
Grid.Row="2" Grid.Column="1"
DataMemberBinding="{Binding Team.Id, Mode=TwoWay}"
ItemsSource="{Binding Teams, Source={StaticResource EscortViewModel}}"
/>
</Grid>
</DataTemplate>
</Grid.Resources>
<StackPanel>
<telerik:RadGridView x:Name="agentViewer"
ItemsSource="{Binding Agents}"
AutoGenerateColumns="False"
RowIndicatorVisibility="Collapsed"
IsReadOnly="True"
>
<telerik:RadGridView.Columns>
<telerik:GridViewToggleRowDetailsColumn />
<telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName, Mode=OneWay}" Header="Name" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Team.Name, Mode=OneWay}" Header="Team" />
</telerik:RadGridView.Columns>
<telerik:RadGridView.RowDetailsTemplate>
<DataTemplate>
<Grid Background="DarkGray">
<Grid Margin="15">
<telerik:RadDataForm x:Name="agentDataEdit"
CurrentItem="{Binding}"
Header="Edit agent:"
AutoGenerateFields="False"
EditTemplate="{StaticResource AgentEditTemplate}"
ReadOnlyTemplate="{StaticResource AgentEditTemplate}"
NewItemTemplate="{StaticResource AgentEditTemplate}"
>
</telerik:RadDataForm>
</Grid>
</Grid>
</DataTemplate>
</telerik:RadGridView.RowDetailsTemplate>
</telerik:RadGridView>
<Grid Background="DarkGray" x:Name="panelAddNew">
<Grid Margin="15">
<telerik:RadDataForm x:Name="agentDataNew"
Header="Add agent:"
AutoGenerateFields="False"
EditTemplate="{StaticResource AgentEditTemplate}"
ReadOnlyTemplate="{StaticResource AgentEditTemplate}"
NewItemTemplate="{StaticResource AgentEditTemplate}"
ItemsSource="{Binding Agents}"
>
</telerik:RadDataForm>
</Grid>
</Grid>
</StackPanel>
</Grid>
Almost everything works great. In the complete form, i can edit string, long and enum (with DataFormComboBoxField). What i can't do is the binding with the Agent.Team.Id.
In fact, the value from DB is displayed (team "A" or "B"...) but when i edit the form and change the Team (list displayed in the DataFormComboBoxField), it never return in the set of the Agent.Team property.
Am I missing something or did i do something wrong ? Is there a bug or an other syntax for the DataMemberBinding="{Binding Team.Id, Mode=TwoWay}" ?
I would like to not use an Agent.TeamId property but the object please.
Thank you very much.