Hello, I'm a Japanese. Sorry, I can speak English a little.
How to set combobox to cell of XamDataGrid. I saw exsample and news, Used XML resources. but i didn't find how to bind XamComboEditor from ViewModel's collection.
Now, I'm using ObjectDataProviderto to refer to article, but Iwant to use ViewModel collection. how to use it?
ComboBoxItemsProvider and ObjectDataProviderhttp://forums.infragistics.com/forums/p/9408/36631.aspx
<Window.Resources> <!--XamComboEditor Style--> <ObjectDataProvider x:Key="dataProvider" ObjectType="{x:Type local:VehicleTypes}" MethodName="Create" /> <Style x:Key="XamComboEditorStyle1" TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider"> <Setter.Value> <igEditors:ComboBoxItemsProvider ItemsSource="{Binding Source={StaticResource dataProvider}}" DisplayMemberPath="Summary" ValuePath="TypeId" /> </Setter.Value> </Setter> </Style></Window.Resources>
' ------------------------------------------' ViewModelOption Explicit OnOption Strict On
Imports System.Collections.ObjectModelImports Livet
Public Class VehicleSearchViewModel Inherits ViewModel
#Region "コンストラクタ"
Public Sub New() Me.Options = VehicleOptions.Create() Me.Types = VehicleTypes.Create() End Sub
#End Region
#Region "プロパティ"
#Region "Options変更通知プロパティ" Private _Options As IEnumerable(Of Object)
Public Property Options() As IEnumerable(Of Object) Get Return _Options End Get Set(ByVal value As IEnumerable(Of Object)) _Options = value RaisePropertyChanged("Options") End Set End Property#End Region
#Region "Types変更通知プロパティ" Private _Types As IEnumerable(Of Object)
Public Property Types() As IEnumerable(Of Object) <DebuggerStepThrough()> Get Return _Types End Get Set(ByVal value As IEnumerable(Of Object)) _Types = value RaisePropertyChanged("Types") End Set End Property#End Region
#Region "Vehicles変更通知プロパティ" Private _Vehicles As ObservableCollection(Of Vehicle)
Public Property Vehicles() As ObservableCollection(Of Vehicle) Get Return _Vehicles End Get Set(ByVal value As ObservableCollection(Of Vehicle)) _Vehicles = value RaisePropertyChanged("Vehicles")
Me.ClearCommand.RaiseCanExecuteChanged() Me.DetailCommand.RaiseCanExecuteChanged() End Set End Property#End Region
End Class
Thanks.
Hello,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hello Mr.Stoyanov.
I'm glad for the reply from you.
Your cord serves as a reference very much. But It's method base. I want to know how to binding ViewModel's properties.
Thanks for your reply.
I downloaded and tried your project. I read and thought... Do I have to use ObjectDataProvider?
It is the following code which I desire. Is such coding difficult?
class ViewModel : INotifyPropertyChanged {
BindingList<Person> _Persons;
public BindingList<Person> Persons {
get { return _Persons; }
set {
_Persons = value;
this.OnPropertyChanged("Persons");
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name) {
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
<Grid.DataContext>
<local:ViewModel />
</Grid.DataContext>
<Grid.Resources>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ItemsSource" Value="{Binding Persons}" />
</Style>
</Grid.Resources>
my blog http://d.hatena.ne.jp/hilapon/
Hi!
Did someone find a solution? I am also interested in this topic.
Thanks
Hello
No, I couldn't find a solution. Cannot be helped if there is no other way.
I have modified the sample I sent you before, so now it works as you want.
Hope this helps you.
Thank you for your sample.
However, because of other XamComboEditor used in the Grid, this approach does not work.
I tryed to move xamDataGrid's resources. List of the XamComboEditor has been displayed in empty. If you think, this is sure?
Thank you.
thank you for your answer, but I'd like to ask you if it is also possible to do this with a ComboBoxItemsProvider instead of the ItemsSource property.
Maybe I should write a new post explaining the situation.
Thanks,
Chema
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Empty the list of XamComboEditor cause was because I did was remove the "ElementName = grid1" from your code. It was necessary this is. The problem is resolved.
If you have more than one XamComboEditor you can set the x:Key of the Style and set the EditorStyle Property of the Field's FieldSettings to that Style.