Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
Xamgrid and combobox column needed. (I attach a picture)
posted

Hello:

I was searching a lot about this problem but I cannot get results, please help :)

I have a Xamgrid (SL4) bound to a datasource class. One of the bound columns is "coin" column, where the user can select between different coins (€,$, etc..) .

When the grid loads, I need to load these combobox with the description and values for each coin (for example, €  has value 17). From my datasource, I have a field (coin_code)  that would allow to select the correct index in each combo programatically.

So, the user will see the current coin selected  for each row (from the datasource), but too, droppingdown the combo, will see the other coins. When the user changes this selection, the real value I will need is the coin code, and not the description 

 The problem is that I cant get these combobox loaded. They are always empty. I have tried with a combobox out of the xamgrid and it's ok.

here is the XAML code snippet:

---

 <igGrid:XamGrid DataContext="{Binding}" Height="421" HorizontalAlignment="Left" Margin="10,12,0,0" Name="dgDetalle" VerticalAlignment="Top" Width="595">

 

 

 

 

 

<igGrid:XamGrid.Columns>

<igGrid:UnboundColumn Key="Coin">

 

 

 

 

 

<igGrid:UnboundColumn.ItemTemplate>

<DataTemplate>

 

 

 

 

 

 <ComboBox ItemsSource="{Binding Thing.Stuff}" DisplayMemberPath="Name" HorizontalAlignment="Left" Name="comboBox5" VerticalAlignment="Top" Width="120" />

 

 

 

 

 

 </DataTemplate>

 

 

 

 

 

 </igGrid:UnboundColumn.ItemTemplate>

____________________________________

And here the CS:

...

Data data = new Data();

data.Thing = new Thing();

data.Thing.Stuff = new ObservableCollection<Stuff>();

data.Thing.Stuff.Add(new Stuff { Name = "Coin1" });

data.Thing.Stuff.Add(new Stuff { Name = "Coin2" });

data.Thing.Stuff.Add(new Stuff { Name = "Coin3" });

data.Thing.SelectedStuff = data.Thing.Stuff.Last();

DataContext = data;

InitializeComponent();...etc...

Class definition:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

public

 

 

 

class Thing :

INotifyPropertyChanged

{

 

 

 

private ObservableCollection<Stuff

> _Stuff;

 

 

 

public ObservableCollection<Stuff

> Stuff

{

 

 

 

get { return

_Stuff; }

 

 

 

set { _Stuff = value; NotifyPropertyChanged("Stuff"

); }

}

 

 

 

private Stuff

_SelectedStuff;

 

 

 

public Stuff

SelectedStuff

{

 

 

 

get { return

_SelectedStuff; }

 

 

 

set { _SelectedStuff = value; NotifyPropertyChanged("SelectedStuff"

); }

}

 

 

 

 

public event PropertyChangedEventHandler

PropertyChanged;

 

 

 

protected void NotifyPropertyChanged(string propertyName)

{

 

 

 

if (PropertyChanged == null)

{

 return;

}

PropertyChanged(

 

this, new PropertyChangedEventArgs(propertyName));

}

}

 

 

 

public class Stuff : INotifyPropertyChanged

{

 

 

 

private string

_Name;

_Code

 

 

 

public string

Name

{

 

 

 

get { return

_Name; }

 

 

 

set { _Name = value; NotifyPropertyChanged("Name"

); }

public string

Code

{

 

 

 

get { return

_Code; }

 

 

 

set { _Code = value; NotifyPropertyChanged("Code"

); }

}

 

 

 

 

public event PropertyChangedEventHandler

PropertyChanged;

 

 

 

protected void NotifyPropertyChanged(string

propertyName)

{

 

 

 

if (PropertyChanged == null) { return

; }

PropertyChanged(

 

 

this, new PropertyChangedEventArgs

(propertyName));

}

 

}

 

 

 

 Thanks and regards!

 

Xabi

Parents
No Data
Reply Children