I am doing something very similiar, I'm capturing various functionality in various unique UserControls seperate to the Mainpage. Similar to below I am also declaring the map dependency property within my usercontrols. I am able to pass values and populate layers, tables, timeslider data. However, I continue to run into issues when I have controls(Sliders) which are located in a usercontrol and are suppose to effect a graphic layer in the Xaml mainpage.
I'm using a userControl defined as QueryPanel. I am able to run queries within the User Control, and display the graphic results in the MainPage. In the UserControl I am also providing a TimeSlider and seperate Slider for a Heatmap function. However, I cant seem to get either slider to manipulate the layer in the MainPage. I have tested the code, by placing all of the related code within the Mainpage.xaml and cs and it works fine. Just not sure if I am missing something, when I attempt to transfer the sliders into a Usercontrol
Using the below Map Dependency in UserControl QueryPanel.CS
protected static readonly DependencyProperty MapProperty=
DependencyProperty.Register("Map", typeof(Map), typeof(QueryPanel), new PropertyMetadata(OnMapPropertyChanged));
private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
( protected static readonly DependencyProperty MapProperty=
DependencyProperty.Register("Map", typeof(Map), typeof(QueryPanel), new PropertyMetadata(OnMapPropertyChanged));
public Map Map
{
get { return (Map)this.GetValue(MapProperty); }
set
{
this.SetValue(MapProperty, (DependencyObject)value);
}
}
private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
QueryPanel control = d as QueryPanel;
Map newMap = e.NewValue as Map;
if (control != null)
{
control._selectionGraphicslayer = newMap.Layers["Incidents"] as GraphicLayer; //Graphic layer being populated from query
TimeSlider IncidentTimeSlider = control.IncidentTimeSlider as TimeSlider; //Not sure if this is correct, wasnt sure how to connect TimeSliders
control.IncidentTimeSlider = IncidentTimeSlider as TimeSlider;
}
In UserControl.xaml
<esri:TimeSlider x:Name="IncidentTimeSlider"
TimeMode="TimeExtent"
//wasnt sure if I was supposed to provide map binding here
Value="{Binding ElementName=Map}" //If so, should I also include a Map Control within the Query Panel UserControl???
In MainPage assigning Incident Time slider to Map
<ESRI:Map TimeExtent="{Binding ElementName=IncidentTimeSlider, Path=Value}"
additional map code
</ESRI:Map>
Had to manually add some of this code, so let me know if you have any questions.