silverlight柱状图 改变选项事件 和 取消选择
public void T_ConditionSuccess(Object sender, GetConditionCodeRateCompletedEventArgs e)
{
if (e.Error == null)
{
Successrates.Clear();
ConditionCodeChart.Axes.Clear();
ConditionCodeChart.Series.Clear();
foreach (MDXValue mdv in e.Result)
{
ConditionRatioBind src = new ConditionRatioBind();
src.Title = mdv.Title;
src.Value = mdv.MValue * 100;
Successrates.Add(src);
}
ConditionCodeChart.Axes.Clear();
ConditionCodeChart.Series.Clear();
ColumnSeries cls = new ColumnSeries();
cls.ItemsSource = null;
cls.ItemsSource = Successrates;
cls.IndependentValueBinding = new Binding("Title");
cls.DependentValueBinding = new Binding("Value");
cls.AnimationSequence = AnimationSequence.FirstToLast;
cls.IsSelectionEnabled = true;
cls.SelectionChanged += new SelectionChangedEventHandler(cs_SelectionChanged);
cls.Title = "设备比例";
ConditionCodeChart.Series.Add(cls);
//ConditionCodeChart.Title = "特征码设备比例";
Title += "特征码设备比例";
ConditionCodeChart.Title = Title;
}
else
{
Alerts.ShowError(e.Error.ToString());
}
}
(ConditionCodeChart.Series[0] as ColumnSeries).SelectedItem = null;
这句话代表取消选择。
void cs_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ColumnSeries cs = (ColumnSeries)sender;
if ((ConditionCodeChart.Series[0] as ColumnSeries).SelectedItem!=null)
{
string str = cs.SelectedItem.ToString();
string name = ((ConditionRatioBind)cs.SelectedItem).Title;
string param = string.Empty;
if (name.Contains("语音"))
{
param = "语音";
}
if (name.Contains("短信"))
{
param = "短信";
}
if (name.Contains("GPRS"))
{
param = "GPRS";
}
ConditionDetailInfos tpu = new ConditionDetailInfos();
tpu.ConditionDetailInfosLoad(null, sAreaName, sDateTime, param);
tpu.Show();
(ConditionCodeChart.Series[0] as ColumnSeries).SelectedItem = null;
}
}