POST
|
I need some help with re-templating the Legend Control, specifically the vertical scrollbar. From what I have read the Legend uses a treeview to display content and the treeview contains a scroll viewer. I have a customized scroll viewer that uses the style of vertical scrollbar that I want. How does one go about changing the template of the treeview used for the legend control to use my custom scrollviewer. The only reference in the template for the Legend to treeview is for TreeViewExtended, shown below: <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="esri:Legend"> <esriToolkitPrimitives:TreeViewExtended BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" ItemsSource="{TemplateBinding LayerItemsSource}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"> <esriToolkitPrimitives:TreeViewExtended.ItemTemplate> <sdk:HierarchicalDataTemplate ItemsSource="{Binding LayerItemsSource}"> <ContentPresenter ContentTemplate="{Binding Template}" Content="{Binding}"/> </sdk:HierarchicalDataTemplate> </esriToolkitPrimitives:TreeViewExtended.ItemTemplate> </esriToolkitPrimitives:TreeViewExtended> </ControlTemplate> </Setter.Value> </Setter> I am having trouble figuring out the syntax to add a new TreeView, any examples and help would be much appreciated. Thanks!
... View more
11-20-2013
09:32 AM
|
0
|
4
|
864
|
POST
|
If you are displaying your results in a datagrid you can create a template column to properly format your hyperlink and build the first part of the url to your file. For example if in your attribute table you are only storing the attachment file name, file.pdf for example, you could create a template column in your xaml like this:
<UserControl.Resources>
<DataTemplate x:Key="DocSource">
<HyperlinkButton Foreground="White" NavigateUri="{Binding Attributes[source_doc], StringFormat=http://www.YourSite/SourceDocs/\{0\}}" Content="{Binding Attributes[source_doc]}" TargetName="_blank" />
</DataTemplate>
</UserControl.Resources>
Then in your QueryTask_ExecuteCompleted you would build the datagrid columns at runtime, rather than before hand. As you loop through the featureset to generate your columns you listen for the field source_doc. When you get to that column you generate the column using the DataTemplate above. ExecuteCompleted Code
if (featureSet != null && featureSet.Features.Count > 0)
{
int rec = 0;
foreach (var feature in featureSet.Features)
feature.Attributes["Rec"] = ++rec;
List<string> fields = new List<string>();
//generate the first column for record index
DataGridTextColumn dataGridTextColumnRec = new DataGridTextColumn();
Binding Recbinder = new Binding();
Recbinder.Path = new PropertyPath("Attributes[Rec]");
dataGridTextColumnRec.Header = "Rec";
Recbinder.Mode = BindingMode.OneWay;
dataGridTextColumnRec.Binding = Recbinder;
QueryDetailsDataGrid.Columns.Add(dataGridTextColumnRec);
//generate the other columns
foreach (var item in featureSet.FieldAliases)
{
if (item.Value == "source_doc") //Create a hyperlink column for document link
{
DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();
templateColumn.Header = "Source Doc";
templateColumn.CellTemplate = (DataTemplate)Resources["DocSource"];
QueryDetailsDataGrid.Columns.Add(templateColumn);
}
else
{
DataGridTextColumn dataGridTextColumn = new DataGridTextColumn();
Binding binder = new Binding();
fields.Add(item.Value); //FieldAliases is a Dictionary, the field name being the key and the field alias being the value.
binder.Path = new PropertyPath("Attributes[" + item.Key + "]");
dataGridTextColumn.Header = item.Value;
binder.Mode = BindingMode.TwoWay ;
dataGridTextColumn.Binding = binder;
QueryDetailsDataGrid.Columns.Add(dataGridTextColumn);
}
}
foreach (Graphic feature in featureSet.Features)
{
feature.Symbol = LayoutRoot.Resources["DefaultResultLineSymbol"] as LineSymbol;
selectionGraphicslayer.Graphics.Insert(0, feature);
}
}
You can create as many data templates as you need, then add another if statement to listen for them. Hope this helps!
... View more
11-20-2013
06:38 AM
|
0
|
0
|
1151
|
POST
|
What method are you using to calculate your buffer distance, Geodesic or Planar? I have found that in my neck of the woods, Washington State, that the planar projection when used for calculating distances is very inaccurate. I always have to use Geodesic in my apps. ESRI has an example of adding a buffer to a point found here,http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#BufferPoint, but I am sure that you have already seen that. Hope that helps!
... View more
11-20-2013
06:20 AM
|
0
|
0
|
380
|
POST
|
I don't know if you figured this out yet, but I have a solution for you if you haven't. Using a converter, like you mentioned, you can bind your thumbnail image to the source of an image control, example: <Image Source="{Binding [Thumbnail_Image], Converter={StaticResource uriConverter}}"/> Below is the code for the converter class:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Converters
{
public class UriConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string uri = value as string;
if (uri != null)
return "http://www.YourSite.com/Thumbnails/" + uri;
else
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
} Hope this helps!
... View more
11-19-2013
07:15 AM
|
0
|
0
|
533
|
POST
|
Over on Codeplex there is a reference to v3.2 that was posted on November 4th. So hopefully they are getting close. Also to the OP, you can find the source code to the api at Codeplex. http://esrisilverlight.codeplex.com/releases/view/114370
... View more
11-19-2013
06:56 AM
|
0
|
0
|
335
|
POST
|
When printing/exporting a map from a secured service, you have to create a new ExportWebMap GP Task. You can't use the default one. You can find instructions here: http://resources.arcgis.com/en/help/main/10.1/#/Printing_maps_that_contain_secured_services/0154000005q3000000/ You will need to create a service account in AD that has read permissions to your secured services. When you setup your new ExportWebMap GP, you will add the service account so the task can actually connect to the services you want to export. I just went through this myself. The instructions above are pretty straightforward but let me know if you have anymore questions.
... View more
11-19-2013
06:45 AM
|
0
|
0
|
322
|
POST
|
Looking for some help when using Touch.FrameReported. I wanted to add drag scroll to my scroll viewers and have tried a variety of different things, none of which worked very well. I have figured out a solution and have the functionality that I want, but I have run into a snag when pinching or stretching to zoom in or out of the map. If pinch or stretch is used the map zooms in or out as expected however it won't refresh itself until you touch the map again with one finger. Then the map pans (jumps) to where you touched and refreshes like its supposed to. Panning with one figure works fine, the map refreshes without issue and performs as expected. It just happens when trying to zoom. I am sure that it has to do with the fact that it is a multipoint gesture, but I can't figure out how to filter that out in the Touch.FrameReported event. My code is below. public MainPage()
{
InitializeComponent();
Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);
}
MPScroll is the scrollviewer that I am applying the drag scroll to. void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
TouchPoint touchPoint = e.GetPrimaryTouchPoint(this.MPScroll);
Point touchedPosition = touchPoint.Position;
if (touchedPosition.X > 0 && touchedPosition.Y > 0 && touchedPosition.X < this.MPScroll.ActualWidth && touchedPosition.Y < this.MPScroll.ActualHeight)
{
if (touchPoint.Action == TouchAction.Down)
{
this.startX = touchedPosition.X;
this.currentScrollX = this.MPScroll.HorizontalOffset;
}
else if (touchPoint.Action == TouchAction.Move)
{
double xMoved = touchedPosition.X - this.startX;
this.MPScroll.ScrollToHorizontalOffset(this.currentScrollX - xMoved);
}
}
} I am completely stumped on this one, any help is appreciated. ~Bob
... View more
08-15-2013
02:39 PM
|
0
|
0
|
577
|
POST
|
I got it figured out and thought I should post to help the next person out. Found parts of this code buried in these forums and modified it to work like I wanted it to. Right now I have the code below wired up the keyboards delete key, but the code can easily be modified to work with a button in your app. When the delete key is pressed the last object drawn to the graphics layer is deleted. You can continue to hit delete until the last object on your graphics layer is removed. void MyMap_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { var l = MyMap.Layers["Drawing Layer"] as GraphicsLayer; if (l != null) { var graphic = l.Graphics.LastOrDefault(g => g.Geometry != null); if (graphic != null) l.Graphics.Remove(graphic); //check if this returns true/false. } } }
... View more
08-15-2013
02:21 PM
|
0
|
0
|
189
|
POST
|
Hoping someone could point me in the right direction to delete an entire object that has been selected when using EditGeometry. The editor widget has this functionality but I cannot tell what it is doing behind the scenes to do this. Thanks in advance!
... View more
08-09-2013
10:27 AM
|
0
|
0
|
463
|
POST
|
I have an application that allows my users to create simple maps during planning meetings. I am using parts of the "Add interactively" sample found here. In addition to the clear graphics button, like in the example, I want to code up something that would allow an "undo" action in case the user makes a mistake. Even if it only steps back one drawing action, that would be a whole lot better than starting over with the clear button. I have been looking at the UndoLastVertex method within the Draw class, but am having issues with getting it to work. There is a very good chance that I am using it wrong and was hoping someone could point me in the right direction or provide an example of what I am trying to accomplish. What I am trying now is simply running the line of code below when the "Undo" button is clicked. MyDrawObject.UndoLastVertex(); Again, I have to imagine that I am missing something. For example, does the graphics layer need to be in some sort of edit session while the user is drawing? Or is it as simple as the line of code above and I have something else screwy going on? Thanks in advance!
... View more
08-08-2013
09:07 AM
|
0
|
1
|
537
|
POST
|
I am using the measuring tools and have found them to be adequate depending on how big of an area or how long of a distance your are measuring. I tested them by measuring known distances, for example a football field. I found it to be pretty close, within 6 inches or so when measuring 20 yards. It was however off by almost 3 yards when measuring 100 yards. Granted there will be some variance depending on how good your aerial imagery is. I would say that they should be used for simple approximations and general planning purposes only, the quick and dirty stuff. They are certainly no substitute for a survey.
... View more
05-07-2013
02:34 PM
|
0
|
0
|
260
|
POST
|
The Geometry field does exist in the database so your code, which loops on fields, creates a column for the geometry. You could exclude it by testing the field type and skip type geometry I finally got around to investigating and solving this issue for good so I figured I should post my solution. Using dbroux's suggestion, during the AutoGeneratingColumn event for the datagrid I cancelled the column generation for the unwanted columns. private void QueryDetailsDataGrid_AutoGeneratingColumn(object sender, System.Windows.Controls.DataGridAutoGeneratingColumnEventArgs e) { //Stop unwanted columns from being generated. string headername = e.Column.Header.ToString(); switch (headername) { case "Geometry": case "Symbol": case "Attributes": case "MapTip": case "TimeExtent": case "Selected": case "Dispatcher": e.Cancel = true; break; } } Thanks for getting me pointed in the right direction!
... View more
05-07-2013
02:19 PM
|
0
|
0
|
333
|
POST
|
Ok so after a bunch of searching the forums for people with similar issues I have modified my code to dynamically generate the columns on its own based on the query results. Before I was manually adding them for every different situation, definitely not the way to do it...But this works great! Well it mostly works great. The results for some reason still tack on those extra Geometry attribute columns for every result. Strange, any idea's? My Modified code: private void MySelectionObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
{
ResultsDisplay.Visibility = Visibility.Visible;
MySelectionObject.IsEnabled = false;
selectionGraphicslayer.ClearGraphics();
//Search Facilities Service - Facilities Layer
if (ddlSelectSystem.SelectedIndex == 0) //Facilities Service
{
if (ddlSelectLayer.SelectedIndex == 0) //Facilities Layer
{
QueryTask queryTask = new QueryTask("myMapServiceURL");
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
queryTask.Failed += QueryTask_Failed;
// Bind data grid to query results
Binding resultFeaturesBinding = new Binding("LastResult.Features");
resultFeaturesBinding.Source = queryTask;
QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding);
Query query = new ESRI.ArcGIS.Client.Tasks.Query();
// Specify fields to return from query
query.OutFields.Add("FAC_ID, SHORT_NAME, FULL_NAME, ACQUI_YEAR, LAT, LONG, NORTHING, EASTING, USE_CD, USE_DESC, Area_Num, Addr_Num, Addr_Name, Addr_Pre, Addr_Sufix, City_Name, CNTY_Name, Floor_CNT, Area_Name, Zip_Code, Gross_SQFT");
query.Geometry = args.Geometry;
// Return geometry with result features
query.ReturnGeometry = true;
query.OutSpatialReference = MyMap.SpatialReference;
queryTask.ExecuteAsync(query);
}
}
//Search Chilled Water System - Valves Layer
} private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
FeatureSet featureSet = args.FeatureSet;
if (featureSet == null || featureSet.Features.Count < 1)
{
//MessageBox.Show("No features returned from query");
return;
}
if (featureSet != null && featureSet.Features.Count > 0)
{
int rec = 0;
foreach (var feature in featureSet.Features)
feature.Attributes["Rec"] = ++rec;
List<string> fields = new List<string>();
//generate the first column for record index
DataGridTextColumn dataGridTextColumnRec = new DataGridTextColumn();
Binding Recbinder = new Binding();
Recbinder.Path = new PropertyPath("Attributes[Rec]");
dataGridTextColumnRec.Header = "Rec";
Recbinder.Mode = BindingMode.OneWay;
dataGridTextColumnRec.Binding = Recbinder;
QueryDetailsDataGrid.Columns.Add(dataGridTextColumnRec);
//generate the other columns
foreach (var item in featureSet.FieldAliases)
{
DataGridTextColumn dataGridTextColumn = new DataGridTextColumn();
Binding binder = new Binding();
fields.Add(item.Value); //FieldAliases is a Dictionary, the field name being the key and the field alias being the value.
binder.Path = new PropertyPath("Attributes[" + item.Key + "]");
dataGridTextColumn.Header = item.Value;
binder.Mode = BindingMode.TwoWay ;
dataGridTextColumn.Binding = binder;
QueryDetailsDataGrid.Columns.Add(dataGridTextColumn);
}
foreach (Graphic feature in featureSet.Features)
{
feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol;
selectionGraphicslayer.Graphics.Insert(0, feature);
}
ResultsDisplay.Visibility = Visibility.Visible;
}
DataDisplayTitle.Text = featureSet.Features.Count + " - Results Found";
MySelectionObject.IsEnabled = true;
MySelectionObject.DrawMode = DrawMode.None;
}
... View more
03-01-2013
01:47 PM
|
0
|
0
|
333
|
POST
|
I am working on a Utilities application that has about eight different map services (Storm Water, Chilled Water, etc.) that can all be queried individually either through spatial queries, identify's, or finds. In trying to keep the application a little lighter I am using one datagrid to show the results of the queries. I have played around with dynamically adding columns at runtime based on the map service and layer that has been queried. It works well and displays the results prefectly. BUT...I started doing the math on how much code will need to be written to do this for each and every map service and layer within that service and have realized that this is not the best approach. I decided to set the AutoGenerateColumns to true and not add any columns at runtime. Unfortunately when I do this instead of attribute information being displayed the datagrid returns what appears to be the geomtery information for that query. Definitly not the results that I am looking for but the right idea as far as column generation goes. [ATTACH=CONFIG]22315[/ATTACH] I have based my queryTask code on the spatial query example found here. The two way binding of the datagrid results and the map are exactly what I need for my application to do. I know there must be an easy fix that I am missing, please HELP. Below is my code for the DrawComplete and ExecuteCompleted. Thanks in advance. private void MySelectionObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args) { ResultsDisplay.Visibility = Visibility.Visible; MySelectionObject.IsEnabled = false; selectionGraphicslayer.ClearGraphics(); //Search Facilities Service - Facilities Layer if (ddlSelectSystem.SelectedIndex == 0) //Facilities Service { if (ddlSelectLayer.SelectedIndex == 0) //Facilities Layer { QueryTask queryTask = new QueryTask("myMapServiceURL"); queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted; queryTask.Failed += QueryTask_Failed; // Bind data grid to query results Binding resultFeaturesBinding = new Binding("LastResult.Features"); resultFeaturesBinding.Source = queryTask; QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding); Query query = new ESRI.ArcGIS.Client.Tasks.Query(); // Specify fields to return from query query.OutFields.Add("*"); query.Geometry = args.Geometry; // Return geometry with result features query.ReturnGeometry = true; query.OutSpatialReference = MyMap.SpatialReference; queryTask.ExecuteAsync(query); } } } private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet == null || featureSet.Features.Count < 1) { //MessageBox.Show("No features returned from query"); return; } if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic feature in featureSet.Features) { feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol; selectionGraphicslayer.Graphics.Insert(0, feature); } ResultsDisplay.Visibility = Visibility.Visible; } DataDisplayTitle.Text = featureSet.Features.Count + " - Results Found"; MySelectionObject.IsEnabled = true; MySelectionObject.DrawMode = DrawMode.None; } XAML for the datagrid <sdk:DataGrid x:Name="QueryDetailsDataGrid" Grid.Row="1" Width="785" Height="160" AutoGenerateColumns="True" CanUserSortColumns="True" VerticalAlignment="Top" HorizontalAlignment="Left" HeadersVisibility="Column" SelectionChanged="QueryDetailsDataGrid_SelectionChanged" LoadingRow="QueryDetailsDataGrid_LoadingRow" RowStyle="{StaticResource MyCustomRow}" Margin="0,5,0,0"> </sdk:DataGrid>
... View more
03-01-2013
09:24 AM
|
0
|
3
|
686
|
POST
|
Thank You!!! You got me pointed in the right direction! I used the MapGesture Event and did a quick if statement to determine whether the user did a tap then ran my identify task. [INDENT]private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs args) { if (args.Gesture == GestureType.Tap ) { GraphicsLayer layer = this.MyMap.Layers["IdentifyIconGraphicsLayer"] as GraphicsLayer; layer.ClearGraphics(); Graphic graphic2 = new Graphic { Geometry = args.MapPoint, Symbol = this.LayoutRoot.Resources["CougarWait"] as Symbol }; Graphic item = graphic2; layer.Graphics.Add(item); IdentifyTask task = new IdentifyTask("http://......./MapServer"); task.ExecuteCompleted += new EventHandler<IdentifyEventArgs>(this.IdentifyTask_ExecuteCompleted); task.Failed += new EventHandler<TaskFailedEventArgs>(this.IdentifyTask_Failed); IdentifyParameters identifyParameters = new IdentifyParameters { LayerOption = LayerOption.all, SpatialReference = this.MyMap.SpatialReference, MapExtent = this.MyMap.Extent, Width = (int)this.MyMap.ActualWidth, Height = (int)this.MyMap.ActualHeight, Geometry = args.MapPoint }; task.ExecuteAsync(identifyParameters); } }[/INDENT] Thanks again for your help!
... View more
01-08-2013
09:36 AM
|
0
|
0
|
238
|
Title | Kudos | Posted |
---|---|---|
1 | 01-26-2017 04:12 PM |
Online Status |
Offline
|
Date Last Visited |
05-06-2022
01:04 PM
|