Add in the XAML: <ComboBox x:Name="Filter" SelectionChanged="Filter_SelectionChanged" VerticalAlignment="Top" HorizontalAlignment="Center"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>
<ComboBox x:Name="Filter" SelectionChanged="Filter_SelectionChanged" VerticalAlignment="Top" HorizontalAlignment="Center"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>
//After InitializeComponent Filter.ItemsSource = new string[] { "1 = 1", "status = 1", "req_type = 'Graffiti Complaint - Public Property'", "status = 1 and req_type = 'Graffiti Complaint - Public Property'" }; private void Filter_SelectionChanged(object sender, SelectionChangedEventArgs e) { var query = Filter.SelectedItem as string; var l = MyMap.Layers["IncidentsLayer"] as FeatureLayer; if(query == "1 = 1") MyDataGrid.FilterSource = null; else if (query == "status = 1") { MyDataGrid.FilterSource = (from g in l.Graphics where (Int16)g.Attributes["status"] == 1 select g).ToList(); } else if (query == "req_type = 'Graffiti Complaint - Public Property'") { MyDataGrid.FilterSource = (from g in l.Graphics where (string)g.Attributes["req_type"] == "Graffiti Complaint - Public Property" select g).ToList(); } else if (query == "status = 1 and req_type = 'Graffiti Complaint - Public Property'") { MyDataGrid.FilterSource = (from g in l.Graphics where (Int16)g.Attributes["status"] == 1 && (string)g.Attributes["req_type"] == "Graffiti Complaint - Public Property" select g).ToList(); } }
Have you looked at this sample? http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataGridI'm not sure I understand your code-snippet. You are using ComboBox to filter what? graphic attributes? In this case, you can use FeatureDataGrid.FilterSource property.Or is FeatureDataGrid.GraphicsLayer property determined at run-time? This might be related thread: http://forums.arcgis.com/threads/35568-Binding-Query-Result-To-FeatureDataGrid
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.