XAML代码
<ComboBox Height="23" Margin="69,105,111,0" Name="comboBox1" VerticalAlignment="Top" ItemsSource="{Binding StoreTypeTable}" DisplayMemberPath="StoreTypeName" SelectedValuePath="StoreTypeName" IsSynchronizedWithCurrentItem="True" SelectedIndex="0"/>
C#代码:
我的班级:
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; }
}
}
我的页面加载:
StoreTypes _ST = new StoreTypes();
comboBox1.ItemsSource = _ST.StoreTypeTable.Rows;
如何在加载页面时显示组合初始值?
请帮助我。
答案 0 :(得分:1)
您的要求非常不清楚。如果要在ComboBox中选择第一个值,可以执行以下操作:
StoreTypes _ST = new StoreTypes();
comboBox1.ItemsSource = _ST.StoreTypeTable.Rows;
if (comboBox1.Items.Count > 0)
{
comboBox1.SelectedIndex = 0;
}
如果那不是你想要的,请编辑你的问题。