I'm having probelas with the binding of radautocompletebox in raddatagridview , in this example the GridViewComboBoxColumn the ItemsSource works correctly but the ItemsSource RadAutoCompleteBox does not work.
Can anyone help.
*** VIEW
using ViewModels;
using System.Windows;
namespace Windows
{
public partial class frmTestes : Window
{
public frmTestes()
{
InitializeComponent();
this.DataContext = new vmTeste(myConnection, System.DateTime.Now);
}
}
}
**** XAML
<Window x:Name="window"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Windows"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
x:Class="Windows.frmTestes" mc:Ignorable="d" Title="frmTestes" >
<Grid>
<TabControl x:Name="tabControl">
<TabItem Header="TabItem1">
<telerik:RadGridView CanUserDeleteRows="False"
AlternationCount="2"
BorderThickness="0"
ShowGroupPanel="True"
AlternateRowBackground="#FFF0F0F0"
AutoGenerateColumns="False"
RowDetailsVisibilityMode="Collapsed"
RowIndicatorVisibility="Collapsed"
ItemsSource="{Binding linhas}">
<telerik:RadGridView.Columns>
<telerik:GridViewComboBoxColumn Header="Código" MinWidth="110" IsComboBoxEditable="True"
DataMemberBinding="{Binding artigo}"
SelectedValueMemberPath="artigo"
DisplayMemberPath="artigo"
telerik:TextSearch.TextPath="artigo"
ItemsSource="{Binding DataContext.artigos, ElementName=window}">
</telerik:GridViewComboBoxColumn>
<telerik:GridViewDataColumn UniqueName="designacao" Header="Designação" Width="*" DataMemberBinding="{Binding desig1}">
<telerik:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
<telerik:RadAutoCompleteBox SelectedItem="{Binding artigos.desig1, Mode=TwoWay}"
ItemsSource="{Binding DataContext.artigos, ElementName=window}"
SelectionMode="Single"
TextSearchMode="Contains"
DisplayMemberPath="desig1"
SearchText="{Binding desig1}"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</TabItem>
<TabItem Header="TabItem2"/>
</TabControl>
</Grid>
</Window>
**** VIEWMODEL
using System;
using System.Collections.ObjectModel;
using System.Data.SqlClient;
namespace ViewModels
{
public class vmTeste : BaseViewModel
{
public vmTeste(SqlConnection _connection, DateTime _datatrabalho)
{
linhas_ = getLinhasFromSQL(_connection, _datatrabalho);
artigos_ = getArtigosFromSQL(_connection, _datatrabalho);
}
private ObservableCollection<Linha> linhas_;
public ObservableCollection<Linha> linhas
{
get
{
return this.linhas_;
}
set
{
linhas_ = value;
}
}
private ObservableCollection<Artigo> artigos_;
public ObservableCollection<Artigo> artigos
{
get
{
return this.artigos_;
}
}
}
}