2014-09-01 2 views
-1

콤보 상자에서 변경 한 후 내 차트를 업데이트해야합니다. 그리고 이것은 전혀 일어나지 않고,로드 펑크에 업데이트되지 않습니다.콤보 상자의 동적 막대 차트 업데이트

콤보 상자가 제대로 채워지고 있습니다. 및로드 차트 기능은 제대로 입력

에 노력하고 있습니다 "정말 ---- 필요한 도움 !!!!"

XAML 파일

<StackPanel Grid.Column="1" > 
     <ComboBox x:Name="SelectNameCB" FontSize="15" Margin="11,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="207" ItemsSource="{Binding MyComboBoxData}" SelectedItem="{Binding selectedcb, Mode=Default, UpdateSourceTrigger=PropertyChanged}" SelectedIndex="0" /> 
     <DVC:Chart x:Name="mcChart" Margin="10,10,31,0" Height="273" Background="LightGoldenrodYellow" Title="{Binding Text, ElementName=SelectNameCB}" > 
      <DVC:BarSeries Title="Avg. Score" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}" ItemsSource="{Binding ChartData}" Margin="10,10,76,10" AnimationSequence="LastToFirst"/> 

     </DVC:Chart> 

의 ViewModel 파일 - fbvm

namespace charting 
{ 
class fbvm : ViewModelBase, INotifyPropertyChanged 
{ 
    public String eID, loadtoc="A_M"; 

    private List<KeyValuePair<string, float>> _chartData; 
    public List<KeyValuePair<string, float>> ChartData 
    { 
     get 
     { 
      return _chartData; 
     } 
     set 
     { 
      _chartData = value; 
      OnPropertyChanged(() => ChartData); 
     } 
    } 
    private List<string> _MyComboBoxData; 
    public List<string> MyComboBoxData 
    { 
     get 
     { 
      return _MyComboBoxData; 
     } 
     set 
     { 
      _MyComboBoxData = value; 
      OnPropertyChanged(() => MyComboBoxData); 
     } 
    } 



    private string _selectedcb; 
    public string selectedcb 
    { 
     get 
     { 
      loadtoc = _selectedcb; 
      return _selectedcb; 

     } 

     set 
     {    
      _selectedcb = value; 
      OnPropertyChanged(() => selectedcb); 

     } 
    } 



    public fbvm() 
    { 
     MyComboBoxData = new List<string>(); 
     comboboxload(); 
     ChartData = new List<KeyValuePair<string, float>>(); 
     LoadColumnChartData(loadtoc); 
     } 

    private void comboboxload() 
    { 
     OleDbConnection ConDb; 

     ConDb = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Admin\\Documents\\Visual Studio 2012\\Projects\\Feedback\\Feedback.accdb"); 

     try 
     { 
      ConDb.Open(); 
      OleDbCommand DBSelect = new System.Data.OleDb.OleDbCommand("select FName, LName,ID_NAME from NameList", ConDb); 
      OleDbDataReader reader = DBSelect.ExecuteReader(); 
      while (reader.Read()) 
      { 
       string eNAME = ""; 
       eID = reader["ID_NAME"].ToString(); 
       eNAME += reader["FName"].ToString(); 
       eNAME += " " + reader["LName"].ToString(); 

       MyComboBoxData.Add(eNAME); 

      } 

     } 
     catch (Exception ae) 
     { 
      MessageBox.Show(ae.Message); 

     }//catch 




    } 
    public void LoadColumnChartData(string loadtodb) 
    { 
     int cc1=0,tc1=0,aa1=0,blfe1=0,count=0; 
     float cc11 = 0, tc11 = 0, aa11 = 0, blfe11 = 0; 
     string str = loadtoc; 
     string[] output = str.Split(' '); 
     foreach (string s in output) 
     { loadtodb = str[0] + "_"; 
     } 
     OleDbConnection connect = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Admin\Documents\Visual Studio 2012\Projects\Feedback\Feedback.accdb"); 
     connect.Open(); 
     string query = "select CC,TC,AA,BLFE,WMU from " +loadtoc; 
     OleDbCommand select = new OleDbCommand("select", connect); 
     select.CommandText = query; 
     OleDbDataReader reader = select.ExecuteReader(); 
     while (reader.Read()) 
     { 
      cc1 += Int32.Parse(reader[0].ToString()); 
      tc1 += Int32.Parse(reader[1].ToString()); 
      aa1 += Int32.Parse(reader[2].ToString()); 
      blfe1 += Int32.Parse(reader[3].ToString()); 
      ++count; 
     } 
     cc11 =(float) cc1/count; aa11 =(float) aa1/count; 
     tc11 =(float) tc1/count; blfe11 =(float) blfe1/count; 
     ChartData.Add(new KeyValuePair<string, float>("cc", cc11)); 
     ChartData.Add(new KeyValuePair<string, float>("tc", tc11)); 
     ChartData.Add(new KeyValuePair<string, float>("aa", aa11)); 
     ChartData.Add(new KeyValuePair<string, float>("blfe", blfe11)); 
     ChartData = new List<KeyValuePair<string, float>>(ChartData); 

    }//loadcoloumnchart 


    #region INotifyPropertyChanged Members 

    /// <summary> 
    /// Need to implement this interface in order to get data binding 
    /// to work properly. 
    /// </summary> 
    /// <param name="propertyName"></param> 
    private void NotifyPropertyChanged(string propertyName) 
    { 
     if (PropertyChanged != null) 
     { 
      PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 
     } 
    } 

    public event PropertyChangedEventHandler PropertyChanged; 

    #endregion 

}//class fbvm 

} // 네임 스페이스

답변

0

문제가 해결되었습니다. 감사합니다 !! ****

namespace charting 
{ 

class fbvm : ViewModelBase, INotifyPropertyChanged 
{ 
    OleDbConnection ConDb; 
    public String eID; 

    public string _Indexname; 
    public string Indexname 
    { 
     get 
     { 
      return _Indexname; 
     } 
     set 
     { 
      _Indexname = value; 

      LoadColumnChartData(Indexname); 
      OnPropertyChanged(() => Indexname); 
     } 
    } 

    private List<KeyValuePair<string, float>> _chartData; 
    public List<KeyValuePair<string, float>> ChartData 
    { 
     get 
     { 
      return _chartData; 
     } 
     set 
     { 
      _chartData = value; 
      OnPropertyChanged(() => ChartData); 
     } 
    } 
    private List<string> _MyComboBoxData; 
    public List<string> MyComboBoxData 
    { 
     get 
     { 
      return _MyComboBoxData; 
     } 
     set 
     { 
      _MyComboBoxData = value; 
      OnPropertyChanged(() => MyComboBoxData); 
     } 
    } 



    public fbvm() 
    { 
     MyComboBoxData = new List<string>(); 
     comboboxload(); 
    } 

    private void comboboxload() 
    { 
     ConDb = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\\\CORE-2\\Jeevanawashyak\\Feedback.accdb"); 
     try 
     { 
       ConDb.Open(); 
       OleDbCommand DBSelect = new System.Data.OleDb.OleDbCommand("select FName, LName,ID_NAME from NameList", ConDb); 
       OleDbDataReader reader = DBSelect.ExecuteReader(); 
       while (reader.Read()) 
       { 
        string eNAME = ""; 
        eID = reader["ID_NAME"].ToString(); 
        eNAME += reader["FName"].ToString(); 
        eNAME += " " + reader["LName"].ToString(); 

        MyComboBoxData.Add(eNAME); 
       } 
      } 
      catch (Exception ae) 
      { 
       MessageBox.Show(ae.Message); 

      }//catch 
    } 
    private void LoadColumnChartData(string Ind) 
    { 
     ChartData = new List<KeyValuePair<string, float>>(); 
     int count2 = 0; 
     string temp = Ind; 
     string temptodb = null; 
     foreach (var part in temp.Split(' ')) 
     { 
      temptodb += part.Substring(0, 1); 
      if(count2<1) 
      temptodb += "_"; 
      count2++; 
     } 
     int cc1=0,tc1=0,aa1=0,blfe1=0,count=0; 
     float cc11 = 0, tc11 = 0, aa11 = 0, blfe11 = 0; 
     string query = "select CC,TC,AA,BLFE,WMU from "+temptodb; 
      OleDbCommand select = new OleDbCommand("select", ConDb); 
      select.CommandText = query; 
      OleDbDataReader reader = select.ExecuteReader(); 
      while (reader.Read()) 
      { 
       cc1 += Int32.Parse(reader[0].ToString()); 
       tc1 += Int32.Parse(reader[1].ToString()); 
       aa1 += Int32.Parse(reader[2].ToString()); 
       blfe1 += Int32.Parse(reader[3].ToString()); 
       ++count; 
      } 
      cc11 = (float)cc1/count;aa11 = (float)aa1/count; 
      tc11 = (float)tc1/count; blfe11 = (float)blfe1/count; 
      // cc11 = 3.11f; 
      // MessageBox.Show(cc11.ToString(), tc11.ToString()); 
      ChartData.Add(new KeyValuePair<string, float>("Communication", cc11)); 
      ChartData.Add(new KeyValuePair<string, float>("Topic Coverage", tc11)); 
      ChartData.Add(new KeyValuePair<string, float>("Audience Attn.", aa11)); 
      ChartData.Add(new KeyValuePair<string, float>("Body Language & Facial Expr.", blfe11)); 
      ChartData = new List<KeyValuePair<string, float>>(ChartData); 

    }//loadcoloumnchart 



}//class fbvm 

} // 네임 스페이스

0

와우. 필자의 시스템에서는이 코드에 대한 경고에 대한 메트릭을 얻을 수 있습니다. 그렇지 않다면 아마도 시스템을 조정하고 경고를 청취 할 시간입니다. 경고 메시지를 받으려면 100 % 확신 할 수 있습니다.

ViewModelBase은 이미 INotifyPropertyChanged을 구현합니다. 다시 구현하면 여기에서 설명하는 것보다 더 많은 문제가 발생합니다. 수퍼 플로 런트 자신의 구현을 INotifyPropertyChanged 클래스에서 제거하십시오. 즉 ViewModelBase이 대상입니다.

코드의 다른 문제를 알고 싶다면 좋은 컴파일러를 얻고 경고 수준을 조정하십시오. 기회는 당신이 이미 당신을 위해이 일을하는 도구를 소유하고, 인간이 인터넷을 통해 할 필요가 없습니다.