I am created silverlight application ,in that application two user control in 1st usercontrol i put combobox and as per selected that combobox value bind chart in another usercontrol . i am try pass that combo box value to another usercontrol .follow my two user control code
1) combobox.xaml
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:ee="http://schemas.microsoft.com/expression/2010/effects"
mc:Ignorable="d"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
d:DesignHeight="300" d:DesignWidth="400" >
2)ChartUserControl.xaml
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
xmlns:telerikCharting="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
x:Name="parent"
mc:Ignorable="d" >
ChartUserControl.xaml.cs
public ChartUserControl()
{
InitializeComponent();
radChart.DefaultView.ChartLegend.Visibility = Visibility.Collapsed;
PieSeriesDefinition piechart = new PieSeriesDefinition();
radChart.DefaultSeriesDefinition = piechart;
MainViewModel mvm = new MainViewModel();
DataContext = mvm;
radChart.ItemsSource = mvm.customers;
}
here MainViewModel code
public class MainViewModel
{
private Service1Client client;
public MainViewModel()
{
client = new Service1Client();
client.TypeSolutionAsync();
client.GetGridDetailAsync();
client.SolutionAsync();
client.GetGridDetailCompleted += new EventHandler
client.SolutionCompleted += new EventHandler
this.solution = new ObservableCollection
this.customers = new ObservableCollection
this.Gridobjects = new ObservableCollection
client.TypeSolutionCompleted += new EventHandler
}
public void client_TypeSolutionCompleted(object o, TypeSolutionCompletedEventArgs e)
{
if (e.Error == null && e.Result != null)
{
foreach (displaydata c in e.Result)
{
this.customers.Add(c);
}
}
}
public void client_GetGridDetailCompleted(object o, GetGridDetailCompletedEventArgs e)
{
if (e.Error == null && e.Result != null)
{
foreach (GridData c in e.Result)
{
this.Gridobjects.Add(c);
}
}
}
public void client_SolutionCompleted(object o, SolutionCompletedEventArgs e)
{
if (e.Error == null && e.Result != null)
{
foreach (SolutionData c in e.Result)
{
this.solution.Add(c);
}
}
}
public ObservableCollection
{
get;
set;
}
public ObservableCollection
{
get;
set;
}
public ObservableCollection
{
get;
set;
}
}
please help to solve this problem
Jignesh TrivediPosted Jun 14, 2012, 3:16 AM
please refer
http://www.dotnetcurry.com/ShowArticle.aspx?ID=166
http://www.dotnetfunda.com/articles/article201.aspx
Other idea is use DataContext to pass value
http://csharperimage.jeremylikness.com/2010/01/simple-dialog-service-in-silverlight.html
hope this will help you.
Santhosh Kumar JayaramanPosted Jun 14, 2012, 3:12 AM
Do both the user controls use same viewmodel? If so, set a new property for selected value.
else,
how you are going to call chart user control from combobox user control.Let us know the flow. we can suggest you