<TextBox Text="{Binding [ST_NAME], Mode=OneWay}"/> <TextBox Text="{Binding [PROJECT], Mode=OneWay}"/>
Have you tried post# 7? I did not use any DataForm but just a StackPanel with TextBlocks for simplicity. The values change when ComboBox Selection changes. It should be the same idea when you use your DataForm. It is critical that you know the fields so you can bind to them in XAML. Note also that you cannot expect a field that is not included in the query to show unless you had specified them in the OutFields or "*".
<toolkit:DataForm x:Name="IdentifyDataForm3" ItemsSource="{Binding}" HorizontalAlignment="Left" MinWidth="400" MaxWidth="500" Margin="4" Grid.Column="1"> <toolkit:DataForm.EditTemplate> <DataTemplate> <StackPanel> <sdk:Label Content="Street Name:"/> <toolkit:DataField> <TextBox Text="{Binding ST_NAME, Mode=OneWay}"/> </toolkit:DataField> <sdk:Label Content="Project:"/> <toolkit:DataField> <TextBox Text="{Binding PROJECT, Mode=OneWay}"/> </toolkit:DataField> </StackPanel> </DataTemplate> </toolkit:DataForm.EditTemplate> </toolkit:DataForm> <toolkit:DataForm x:Name="dataForm" Width="350" ItemsSource="{Binding}" HorizontalAlignment="Left" MaxWidth="500" Margin="4" Grid.Column="1" VerticalAlignment="Center"/> <StackPanel x:Name="MyForm" VerticalAlignment="Top" HorizontalAlignment="Center" Orientation="Vertical"> <StackPanel Orientation="Horizontal"> <TextBlock Text="Name: "/> <TextBlock Text="{Binding [ST_NAME]}"/> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock Text="Project: "/> <TextBlock Text="{Binding [PROJECT]}"/> </StackPanel> </StackPanel>
void cb_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = IdentifyComboBox.SelectedIndex; if (index > -1) try { IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data; IdentifyDataForm3.DataContext = _dataItems[index].Data ; //////////////////////////////// dataForm.DataContext = _dataItems[index].Data ; MyForm.DataContext = _dataItems[index].Data; } catch { } }
You are using Silverlight Data Form now, right? This is not the same as FeatureDataForm from our Toolkit. The fields in the FeatureDataForm come from the FeatureLayer.OutFields. How they are displayed on the form is dependent on the data type defined by the service.
Have you looked at this SL4 Toolkit sample? http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html. Look at the Template-Driven sample. I think you need to define template for each layer since they will have different fields. A simpler example will be this. Add the following XAML-code to the Identify SDK sample: <StackPanel x:Name="MyDataForm" VerticalAlignment="Top" HorizontalAlignment="Center" Orientation="Horizontal"> <TextBlock Text="State Name: "/> <TextBlock Text="{Binding [STATE_NAME]}"/> </StackPanel> In code-behind, set its DataContext when DataGrid gets its ItemsSource. void cb_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = IdentifyComboBox.SelectedIndex; if (index > -1) { IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data; MyDataForm.DataContext = _dataItems[index].Data; } }
<StackPanel x:Name="MyDataForm" VerticalAlignment="Top" HorizontalAlignment="Center" Orientation="Horizontal"> <TextBlock Text="State Name: "/> <TextBlock Text="{Binding [STATE_NAME]}"/> </StackPanel>
void cb_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = IdentifyComboBox.SelectedIndex; if (index > -1) { IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data; MyDataForm.DataContext = _dataItems[index].Data; } }
This sample http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify assumes that the IdentifyComboBox will contain titles and IdentifyDetailsDataGrid will contain the feature attributes. This sample uses DataItem class to update the IdentifyDetailsDataGrid source on IdentifyComboBox SelectionChanged event.You need to update the XAML-code for IdentifyDetailsDataGrid and replace it with your own data form. You also need to know which layer the feature belongs to in order to know the fields you need for Binding.For example: <StackPanel Orientation="Horizontal"> <TextBlock Text="State Name: "/> <TextBlock Text="{Binding [STATE_NAME]}"/> </StackPanel>
<StackPanel Orientation="Horizontal"> <TextBlock Text="State Name: "/> <TextBlock Text="{Binding [STATE_NAME]}"/> </StackPanel>
<toolkit:DataForm x:Name="IdentifyDataForm2" AutoGenerateFields="False" IsReadOnly="True" IsEnabled="True" LabelPosition="Left" Height="150" VerticalAlignment="Top"> <StackPanel Orientation="Horizontal"> <TextBlock Text="Name: "/> <TextBlock Text="{Binding [ST_NAME]}"/> </StackPanel> </toolkit:DataForm>
void cb_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = IdentifyComboBox.SelectedIndex; if (index > -1) IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data; IdentifyDataForm2.ItemsSource = _dataItems[index].Data ; //////////////////////////////// }
IdentifyDataForm2.ItemsSource = feature.Attributes;
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args) { IdentifyDetailsDataGrid.ItemsSource = null; if (args.IdentifyResults != null && args.IdentifyResults.Count > 0) { IdentifyResultsPanel.Visibility = Visibility.Visible; IdentifyDataForm2.DataContext = args.IdentifyResults.Feature.Attributes ; ShowFeatures(args.IdentifyResults); } else { IdentifyComboBox.Items.Clear(); IdentifyComboBox.UpdateLayout(); IdentifyResultsPanel.Visibility = Visibility.Collapsed; } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.