|
POST
|
You don't need to use the FeatureDataGrid or FeatureDataForm, they do add some nice features to the standard Silverlight toolkit tools. There would be slightly different approaches because with the FeatureDataGid you are bound to the FeatureLayer directly. Here is how I have done it. Following the sample here http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#QueryRelatedRecords I get my related records when the user selects the related point This next steps would depend on which grid you use With the SL Grid: Create a collection of some sort of objects that show my attributes (like the Inspection object shown here http://forums.arcgis.com/threads/21714-Editing-Tables-in-Feature-Service-with-Silverlight-4 from my returned set of Graphics Bind this collection to my data grid To update an existing feature when the user completes edits to the record I query the graphics collection from the FeatureLayer to find the Graphic with the same OID. Then make changes to the attributes in this Graphic and call save on the FeatureLayer So very similar to what he shows but instead of adding to the Graphics collection I query for the Graphic and update its attributes. Also I have found the only way to get the Graphics to load properly in my FeatureLayer is to add the FeatureLayer in Xaml, creating it like in the sample will not load the Graphics collection on the FeatureLayer With the FeatureDataGrid Bind a FeatureLayer (not the actual FeatureLayer in my map, though) to the grid but initially have the FeatureLayer as null Do the related records query as before but when I get the results back I set the ObjectId property on my bound FeatureLayer and call Update() on the FeatureLayer To add a record I need to create the Graphics object and first initialize all my Attributes to their default values for the data type Then can add the record to the FeatureLayer and it will show up in the Grid Then you just call Save() on the FeatureLayer For updates the user is editing the graphic so just need a call to save no searching like before I will try and post a code sample for one of the approaches (probably #2) later when I get everything finished Hope that helps -Joe
... View more
05-29-2012
08:52 PM
|
0
|
0
|
1242
|
|
POST
|
You can look at this thread - how to get graphic from selected row http://forums.arcgis.com/threads/46013-FeatureDataGrid-Selection-Changed-Event Thanks that solve the problem. I think it is worth consideration for the next release to have the SelectedGraphic update in this situation, or have a another property to handle this situation so everything could be done with data binding directly in the xaml. Cheers -Joe
... View more
05-29-2012
07:23 PM
|
0
|
0
|
442
|
|
POST
|
The graphics collection is populated after the initialization phase during the draw of the map. So it's normal that the graphics collection is empty when the Initialized event is fired. You can subscribe to Updated event instead. Also, did you insert your feature layer in a Map? If you didn't, you have to call 'Update' by yourself else the feature layer won't ever be updated. If I call Initialize on the FeatureLayer and then try to call Update I get a null reference error, which is happening internal to the FeatureLayer object (my objects are not null). I added the Update handlers and when the FeatureLayer is added to the map via code it fails on Update with a Error Code 400: Unable to complete operation "Unable to perform query." This occurs whenever I zoom the map. Again this will work when the FeatureLayer is added in xaml Cheers -Joe
... View more
05-29-2012
03:40 AM
|
0
|
0
|
731
|
|
POST
|
I am trying to edit data from an ObjectClass after getting the first set of problems worked out (see http://forums.arcgis.com/threads/58680-Updating-data-in-a-Table) I thought it would be really nice to use the FeatureDataGrid and FeatureDataForm as is mentioned in a previous thread. While this is not required there is certainly some nice functionality there I would like to take advantage of. Setup the FeatureDataGrid no problem but does not seem to me there is a way to integrate the two tools. I would have thought that I could simply get the SelectedItem and that would be a Graphic which I could then set as the GraphicSource. But it seems the SelectedItem is an ESRI.ArcGIS.Client.Toolkit.DataSource.TempType2138779241 (seriously?), which is pretty worthless to me. The SelectedGraphic is also not of any use because it is never populated, I am assuming this is because this is an ObjectClass not a FeatureClass as the source. Maybe I am missing something. I have written a working application using the standard Silverlight Toolkit, but I think these tools are really nice and I would like to use them. Cheers -Joe
... View more
05-29-2012
03:19 AM
|
0
|
2
|
641
|
|
POST
|
I have heard middle of June is planned for release, but you probably want to ask your distributor for a more accurate answer is to when/how you would obtain
... View more
05-29-2012
01:33 AM
|
0
|
0
|
457
|
|
POST
|
If you go to the Code Gallery on the main Silverlight API page and search for print the are a number of samples that come up. If you can hold off a bit I would wait for 10.1 to be released as this has native print support as part of AGS
... View more
05-28-2012
11:00 PM
|
0
|
0
|
457
|
|
POST
|
I have followed the path outlined in the thread on editing records http://forums.arcgis.com/threads/21714-Editing-Tables-in-Feature-Service-with-Silverlight-4 and while that works for adding new records it does not address editing of existing rows in a table which I have found quite difficult partially because of what I would consider a bug with the API. When I create a FeatureLayer object in code like shown in the thread on adding records and call initialize on the FeatureLayer, when the Initialized is returned the Graphics collection is empty even though there are objects in my table. I have played around with different approaches when creating the FeatureLayer, giving OIDs putting a Where clause of ???OBJECTID > 0,??? but in all cases the Graphics collection is empty and never populates. What I have also tried is to add the FeatureLayer to the map in code still no luck. However, when the FeatureLayer is added to the map in Xaml it does have a populated Graphics collection. Why is there is different behavior when adding through Xaml compared to adding in code? I would consider that a bug. Once my Graphics collection is populated I am able to update a record by finding the proper Graphic object and changing the attributes and calling Save. Something along the lines of; Graphic graphic = _featureLayer.Graphics.Where(g => (int)g.Attributes[OBJECTID] == ObjectId).FirstOrDefault(); graphic[NAME] = newValue; _feaureLayer.Save(); Adding the FeatureLayer in Xaml is not really an option in how my application is designed (well it is an option, one that defeats the entire point in having architected a modular MVVM application). To me something is wrong, you should not have to add a FeatureLayer in Xaml to make something work, creating the object in code and calling initialize should have the same behavior. Could someone look into this, perhaps I am missing something. Cheers
... View more
05-28-2012
10:54 PM
|
0
|
4
|
964
|
|
POST
|
I am not exactly clear on what you are describing with how the map is exposed in you view model. You descriptions sounds as though you have a Layers collection on the ViewModel that is bound to the map in Xaml. Something along these lines below.
<esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000" Layers="{Binding MapLayers}">
I have found that it is pretty much impossible to really create an ESRI Silverlight API application without exposing the Map object to the ViewModel, there are just too many things that need the Map object. What I do is have my main page implement an interface that exposes the Map.
public interface IMapView
{
Map Map { get; }
}
I use Dependency Injection (I use MEF, Unity is another Microsoft option) to get my IMapView object into my ViewModels. I don't actually have a ViewModel attached to the MainPage, instead my MainPage is made of numerous views each with it's own ViewModel. From here I would have a View (some kind of toolbar in this case) with an attached ViewModel. For a good navigation tool you kind of need toggle buttons, in my opinion. I have made those as custom controls that inherit from RadioButton. RadioButton because it already includes the behavior of only one being selected at a time, compared to core ToggleButton. There are a few ways to wire the commands, the most straight forward is to have the ViewModel expose an ICommand for each button and a bool for the IsSelected property. Something similar to below
<Buttons:MyToggleButton Text="{Binding Path=LanguageResource.ButtonText, Source={StaticResource LocalizedStrings}}"
IsChecked="{Binding ZoomInIsChecked, Mode=TwoWay}"
Click="{Binding ZoomCommand}" CommandParameter="ZoomIn" GroupName="ZoomButtons"/>
[Import]
public IMapView MapView {get;set;}
private ICommand _zoomCommand;
public ICommand ZoomCommand
{
get { return _zoomCommand?? (_zoomCommand= new DelegateCommand<string>(ExecuteZoomCommand)); }
}
private void ExecuteZoomCommand(string zoomType)
{
//Here would be my zoom logic
}
Something along those lines ties the Command to the view model Hope that helps
... View more
05-26-2012
08:40 AM
|
0
|
0
|
687
|
|
POST
|
ESRI changed these to match with Google and Bing which use WebMercator. This way the tiling scheme is the same for all the primary base maps sources. I cannot see that they would ever change back to WGS as it would mean having to support two different sets of cached maps. I agree that WGS84 makes a lot more sense to use as a projection
... View more
05-26-2012
03:51 AM
|
0
|
0
|
994
|
|
POST
|
Yassine, Sorry about the variable name error, the sample was not actually meant to be used as is, it was intended to show the two possible ways to setup the code depending on if a user was allowed to select only one row, or select more than one row I do not think I am clear about what you are trying to zoom to. What I thought you wanted to do is select a number of points in your map using a spatial query. For example, you would draw a box around a number of points and those points would then show up in the selected points datagrid. Then when you select an item in the data grid it would zoom to that point. So every time you click an item in the grid it zooms to a location on the map. For the sample I changed the code to this:
private void QueryDetailsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (Graphic g in e.AddedItems)
{
g.Select();
MyMap.ZoomTo(g.Geometry);
}
foreach (Graphic g in e.RemovedItems)
g.UnSelect();
}
Which will now zoom to the state that was selected when the user clicks on the item in the datagrid. Can you please try to clarify if this is what you are trying to do. I think that your goal is different from my understanding. Thanks -Joe
... View more
05-26-2012
12:33 AM
|
0
|
0
|
865
|
|
POST
|
You can create a value converter that returns the image URL depending on the field values. Then you can bind the image inside the maptip to the Url coming from this converter. Interesting idea, thanks.
... View more
05-25-2012
07:28 AM
|
0
|
0
|
369
|
|
POST
|
What you are showing does not have anything to do with binding or MVVM so am not sure why are discussing it in that context. In the first line of you code you assign a variable to the GraphicsSource property and so you now have two variables reference that same object. When you make changes to the _graphics variable it is reflected in the GraphicsSource because they both reference that object. When you set _graphics = new ... The _graphics variable now references a new object. The original object that GraphicsSource is referencing has not been affected, GraphicsSource still references the same object it has the entire time. What it seems like you want is to have an object bound to the GraphicsSource.
<esri:GraphicsLayer ID="GL" GraphicsSource="{Binding GraphicsSource, Mode=TwoWay}" />
If you have a class like below that is set as the DataContext for your the GraphicsLayer (e.g., through setting the DataContext on the View with the map in it)
public class MyViewModel : INotifyPropertyChanged
{
private ObservableCollection<Graphic> _graphicsSource;
public ObservableCollection<Graphic> GraphicsSource
{
get { return _graphicsSource; }
set
{
_graphicsSource = value;
PropertyChanged("GraphicsSource");
}
}
#region Implementation of INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if ( PropertyChanged != null )
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
Now something like this would reset the graphics to those contained in someOtherGraphics and it would be reflected in the map
private void ExecuteNewGraphicsCollection()
{
GraphicsSource = new ObservableCollection<Graphic>(someOtherGraphics);
}
Hope that helps
... View more
05-25-2012
12:10 AM
|
0
|
0
|
656
|
|
POST
|
You might want to look at something like Prism (it is part of Microsoft Practices and on codeplex). That is what I have been using for Silverlight applications. It provides a modular framework and an event framework which sounds like what you want. It also provides the ability to use Dependency Injection with either MEF or Unity and a good commanding architecture to help with developing MVVM applications. As an example in my site I have an application that keeps a table of points for graphics that the user is adding to a map. I also have a couple applications that allow the users to draw graphics on a map. Every time the user adds a graphic in one of the drawing applications it sends off an event. The application that keeps the table is listening for that event and when it receives the event updates the table.
... View more
05-24-2012
08:25 PM
|
0
|
0
|
412
|
|
POST
|
In the code example from the sample you pointed to the SelectionChanged Event returns a Graphic collection (IList) as shown below e.AddedItems.
private void QueryDetailsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (Graphic g in e.AddedItems)
g.Select();
foreach (Graphic g in e.RemovedItems)
g.UnSelect();
}
The Graphic object has a Geometry property and your case because you selected points this Geomtry would be a MapPoint object. Something like this below should get the MapPoint you need
private void QueryDetailsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//This would work with multiple points being selected
ESRI.ArcGIS.Client.Geometry.PointCollection points = new ESRI.ArcGIS.Client.Geometry.PointCollection();
foreach ( Graphic g in e.AddedItems )
{
MapPoint mapPoint = g.Geometry as MapPoint;
if (mapPoint != null )
{
points.Add(mapPoint);
}
}
MultiPoint multiPoint = new MultiPoint(points);
MyMap.ZoomTo(multiPoint.Extent);
//If you user was only allowed to select a single point it would be something like this
Graphic g = e.AddedItems[0] as Graphic;
MapPoint mapPoint = g.Geometry as MapPoint;
if (mapPoint != null )
{
MyMap.ZoomToResolution(MyMap.Resolution / MyMap.ZoomFactor, mapPoint); //As shown Above
}
foreach (Graphic g in e.RemovedItems)
g.UnSelect();
}
Hope that helps -Joe
... View more
05-22-2012
08:21 PM
|
0
|
0
|
865
|
|
POST
|
Well it seem it is something to do with when running from IIS you must treat the connection like an internet connection to the service catalog and not like a LAN connection. I changed my PropertySet from setting machine name to setting Url and not it is working Cheers
... View more
05-05-2012
10:49 PM
|
0
|
0
|
391
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-23-2025 12:16 PM | |
| 1 | 10-19-2022 01:08 PM | |
| 1 | 09-03-2025 09:25 AM | |
| 1 | 04-16-2025 12:37 PM | |
| 1 | 03-18-2025 12:17 PM |
| Online Status |
Offline
|
| Date Last Visited |
Thursday
|