Reputation:
XAML Code
<ComboBox Height="23" Margin="69,105,111,0" Name="comboBox1" VerticalAlignment="Top" ItemsSource="{Binding StoreTypeTable}" DisplayMemberPath="StoreTypeName" SelectedValuePath="StoreTypeName" IsSynchronizedWithCurrentItem="True" SelectedIndex="0"/>
C# Code:
My Class:
class StoreTypes:nuClass
{
private WSOntsu.ServiceSoapClient _WS;
private WSOntsu.OSM007StoreType _DS;
public StoreTypes()
{
try
{
_WS = new WpfOntsu.WSOntsu.ServiceSoapClient();
_DS = _WS.lstStoreType();
}
catch (Exception e)
{
bResult = false;
sResult = e.Message;
}
bResult = _DS.Osm007getStoreType.Rows.Count > 0;
}
public DataTable StoreTypeTable
{
get { return _DS.Osm007getStoreType; }
}
}
My Page load:
StoreTypes _ST = new StoreTypes();
comboBox1.ItemsSource = _ST.StoreTypeTable.Rows;
How to display combo initial value when page is loading?
plz help me.
Upvotes: 0
Views: 367
Reputation: 178770
Your request is very unclear. If you want to select the first value in the ComboBox, you can do something like:
StoreTypes _ST = new StoreTypes();
comboBox1.ItemsSource = _ST.StoreTypeTable.Rows;
if (comboBox1.Items.Count > 0)
{
comboBox1.SelectedIndex = 0;
}
If that's not what you want, please edit your question.
Upvotes: 1