Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try such changes</p> <pre><code>public class OwnerOccupierAccountViewModel : ViewModelBase { /// &lt;summary&gt; /// Load combobox structures /// &lt;/summary&gt; private readonly LoadOperation&lt;Structure&gt; _loadStructures; private readonly LoadOperation&lt;UnitOccupierDetail&gt; _loadUnitOccupierDetails; //public ICommand SaveAccountSettingsCommand { get; set; } #region Properties private ObservableCollection&lt;Structure&gt; _structures; public ObservableCollection&lt;Structure&gt; Structures { get { return _structures; } set { _structures = value; RaisePropertyChanged("Structures"); } } private Structure _userStructure; public Structure UserStructure { get { return _userStructure; } set { _userStructure = value; RaisePropertyChanged("UserStructure"); } } private UnitOccupierDetail _unitOccupierDetail; public UnitOccupierDetail UnitOccupierDetail { get { return _unitOccupierDetail; } set { _unitOccupierDetail = value; RaisePropertyChanged("UnitOccupierDetail"); } } #endregion public OwnerOccupierAccountViewModel() { // SaveAccountSettingsCommand = new DelegateCommand(SaveAccountSettings, CanSave); UserAccountContext _userAccountContext; if (!DesignerProperties.IsInDesignTool) { var loggedInUser = new Guid(WebContext.Current.User.UserID.ToString()); _userAccountContext = new UserAccountContext(); #region load structures _loadStructures = _userAccountContext.Load(_userAccountContext.GetStructuresQuery()); _loadStructures.Completed += _loadStructuresCompleted; #endregion #region load user data _loadUnitOccupierDetails = _userAccountContext.Load( _userAccountContext.GetUnitOccupierDetailsQuery().Where( u =&gt; u.UserIDFK == loggedInUser &amp;&amp; u.StructureFK == 92)); _loadUnitOccupierDetails.Completed += _loadUnitOccupierDetails_Completed; #endregion } } void _loadUnitOccupierDetails_Completed(object sender, EventArgs e) { _unitOccupierDetail= new UnitOccupierDetail(); _unitOccupierDetail = _loadUnitOccupierDetails.Entities.First(); _userStructure = _unitOccupierDetail.Structure; } void _loadStructuresCompleted(object sender, EventArgs e) { var theseStructures = new ObservableCollection&lt;Structure&gt;(_loadStructures.Entities); Structures = theseStructures; } //private void SaveAccountSettings(object param) //{ //} //private static bool CanSave(object param) //{ // return true; //} } &lt;ComboBox x:Name="cboApartments" ItemsSource='{Binding Structures, Mode=TwoWay}' DisplayMemberPath='StructureName' SelectedValuePath='IDStructure' SelectedItem='{Binding UserStructure,Mode=TwoWay}' Width="200" Height="25"&gt; </code></pre> <p><strong>Updated:</strong></p> <p>Hmm, maybe try changes here:</p> <pre><code> &lt;ComboBox x:Name="cboApartments" ItemsSource='{Binding Structures, Mode=TwoWay}' SelectedItem='{Binding UserStructure, Mode=TwoWay}' Width="200" Height="25"&gt; &lt;ComboBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Path=StructureName}"/&gt; &lt;/DataTemplate&gt; &lt;/ComboBox.ItemTemplate&gt; &lt;/ComboBox&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload