You need to cast SelectedItem to ComboBoxItem, then access it's Value property :
var i = ((ComboBoxItem)sTD_PROVINCEComboBox.SelectedItem).Value;
With that i
will contain the Value
, so in the foreach
you can simply do as follow :
foreach(var item in UE2.Cities.Where(x => x.CITY_PROVINCE_ID == i)
UPDATE :
Just notice that Value
property of ComboBoxItem
is of type object (I was assuming it is int). If this is the case, the above foreach part won't compile (comparing int with object is not allowed). Assuming CITY_PROVINCE_ID
is of type int, and i
storing boxed int you'll need to unbox i
back to int :
foreach(var item in UE2.Cities.Where(x => x.CITY_PROVINCE_ID == (int)i)