Select to view content in your preferred language

Show identify in a dataform

1512
13
03-09-2011 11:54 AM
DonFreeman
Emerging Contributor
I would like to present the result of an identify query in a dataform rather than a datagrid so that I can control the layout and formatting. Does anyone have a sample of how this would be constructed?
Thanks
0 Kudos
13 Replies
DonFreeman
Emerging Contributor
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.


Yes, I am using (or trying to use) the regular Silverlight dataform. I tried the FeatureDataForm but since you can't reposition the textboxes it doesn't serve my purpose. BUT . . . I still cannot get the data to display except for the first field. Perhaps I need a different type of data entity?
0 Kudos
JenniferNery
Esri Regular Contributor
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 "*".
0 Kudos
DonFreeman
Emerging Contributor
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 "*".


Sorry Jenn, I had missed the subtly of your suggestion. (I had placed the stackpanel inside the dataform.) And Yes! it does work. Which makes me wonder why it will NOT work in the dataform. Look at this:
    <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>

with codebehind:
  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
    {
    }
   }

The plain stackpanel works, but neither of the dataforms will show the requested data. Go figure?
0 Kudos
JenniferNery
Esri Regular Contributor

<TextBox Text="{Binding   [ST_NAME], Mode=OneWay}"/> 
<TextBox Text="{Binding   [PROJECT], Mode=OneWay}"/> 


You need to surround the attribute key with braces [] in the DataForm.DataField as well 🙂
0 Kudos