Grid XAML:
<data:DataGrid x:Name="dgRequestLocationPoints" AutoGenerateColumns="False" MaxHeight="500" Foreground="Black" IsReadOnly="False" >
<data:DataGrid.Columns>
<data:DataGridTextColumn Header="Long" Width="90" Binding="{Binding X, Mode=TwoWay}" IsReadOnly="False" />
<data:DataGridTextColumn Header="Lat" Width="90" Binding="{Binding Y, Mode=TwoWay}" IsReadOnly="False" />
<data:DataGridTemplateColumn Width="50">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="DeletePoint" Click="DeletePoint_Click" Width="16" Height="16">
<Image Source="images/delete.png" Stretch="Fill"/>
</Button>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
</data:DataGrid>
Binding the vertices to the gird:
private void BindGeometryToGrid(ESRI.ArcGIS.Client.Geometry.Geometry Geometry)
{
ESRI.ArcGIS.Client.Geometry.Polygon requestLocationPolygon = Geometry as ESRI.ArcGIS.Client.Geometry.Polygon;
ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection> requestLocationEnvelopPointCollection = requestLocationPolygon.Rings;
ESRI.ArcGIS.Client.Geometry.PointCollection singlePointCollection = requestLocationEnvelopPointCollection[0];
singlePointCollection[singlePointCollection.Count-1] = singlePointCollection[0];
dgRequestLocationPoints.ItemsSource = singlePointCollection;
}
PointLocation.cs Class
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
namespace LocalRelationsModule
{
public class PointLocation : INotifyPropertyChanged
{
private double _X;
private double _Y;
public double X
{
get { return _X; }
set {
_X = value;
//SendPropertyChanged("X");
}
}
public double Y
{
get { return _Y; }
set
{
_Y = value;
//SendPropertyChanged("Y");
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
Delete Point Code Behind:
private void DeletePoint_Click(object sender, RoutedEventArgs e)
{
var selectedIndex = DataGridRow.GetRowContainingElement(sender as FrameworkElement).GetIndex();
lstPointLocation.RemoveAt(selectedIndex);
}
Enjoy Coding
No comments:
Post a Comment