I am trying to bind a null foreign key to a specific value in the combo box itemssource. Below is the relevant code. Do you have any suggestions on how to make this display "None" instead of remaining blank?
/// <summary>
/// Event handler
/// </summary>
private void ClientBiz_OnDataListRefreshed(object sender, ClientBizNew.DataListRefreshedEventArgs e)
{
//Get the xml and clear the respective list.
string xml = this.ClientBiz.GetDataListResult(e.ServiceName, e.QueryName);
if (!string.IsNullOrEmpty(xml))
{
XDocument xd = XDocument.Parse(xml);
if (e.ServiceName.Equals("GLChart"))
{
_chartList.Clear();
_chartList.Add(new GLChartObject() { GLChartKey = null, GLChartName = "None" });
}
//get the xml nodes
var nodes = from x in xd.Descendants(e.ServiceName) select x;
//set the properties in the corresponding data class
foreach (var n in nodes)
{
if (e.ServiceName.Equals("GLChart") && e.QueryName.Equals("GETALL"))
{
int key = Convert.ToInt32(n.Element("PK_GLChart").Value);
string name = n.Element("ChartName").Value;
_chartList.Add(new GLChartObject() { GLChartKey = key, GLChartName = name });
}
}
//set the binding of the respective combo box to the list.
if (e.ServiceName.Equals("GLChart"))
{
this.cboChartOfAccounts.ItemsSource = _chartList;
}
}
}
}
public class GLChartObject
{
public int? GLChartKey { get; set; }
public string GLChartName { get; set; }
}
<bfgs:RadComboBox x:Name="cboChartOfAccounts"
DisplayMemberPath="GLChartName"
SelectedValue="{Binding FK_GLChart, Mode=TwoWay}"
SelectedValuePath="GLChartKey"
FilteringMode="StartsWith"
Grid.Row="1"
Grid.Column="1"
Margin="2,2,2,2"
Height="22"
VerticalAlignment="Top"
TabIndex="6"/>
Thanks for your help.