Select to view content in your preferred language

How to template a FeatureDataForm

3366
2
02-08-2011 05:33 AM
DonFreeman
Emerging Contributor
I am assuming esri's FeatureDataForm can be templated similar to the standard silverlight dataform. Is this correct? If so, can someone point me to a sample so I can see how to set the various values?

Thanks
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor

I am assuming esri's FeatureDataForm can be templated similar to the standard silverlight dataform. Is this correct?

Sure. The easiest way is to use Blend : create a featuredataform, right-click, edit template, edit a copy, ....

If you don't own Blend, I give you the default template:

 
        <Style x:Key="FeatureDataFormStyle1" TargetType="esri:FeatureDataForm">
         <Setter Property="Background">
          <Setter.Value>
           <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFF3F7FA" Offset="0"/>
            <GradientStop Color="#FFFFFFFF" Offset="0.1"/>
           </LinearGradientBrush>
          </Setter.Value>
         </Setter>
         <Setter Property="BorderBrush">
          <Setter.Value>
           <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FFA3AEB9" Offset="0"/>
            <GradientStop Color="#FF8399A9" Offset="0.375"/>
            <GradientStop Color="#FF718597" Offset="0.375"/>
            <GradientStop Color="#FF617584" Offset="1"/>
           </LinearGradientBrush>
          </Setter.Value>
         </Setter>
         <Setter Property="BorderThickness" Value="1"/>
         <Setter Property="Template">
          <Setter.Value>
           <ControlTemplate TargetType="esri:FeatureDataForm">
            <Border x:Name="DataFormBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2">
             <Border.Resources>
              <Style x:Key="CustomScrollViewerStyle" TargetType="ScrollViewer">
               <Setter Property="BorderThickness" Value="0,1"/>
               <Setter Property="Template">
                <Setter.Value>
                 <ControlTemplate TargetType="ScrollViewer">
                  <Grid>
                   <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="0,-1" Opacity="0.2" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}">
                    <Border.OpacityMask>
                     <LinearGradientBrush EndPoint="1.07,0.5" StartPoint="-0.07,0.5">
                      <GradientStop Color="#FF000000"/>
                      <GradientStop Color="#7FFFFFFF" Offset="0.5"/>
                      <GradientStop Color="#FF000000" Offset="1"/>
                     </LinearGradientBrush>
                    </Border.OpacityMask>
                   </Border>
                   <Grid Background="{TemplateBinding Background}">
                    <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="*"/>
                     <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                     <RowDefinition Height="*"/>
                     <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ScrollContentPresenter x:Name="ScrollContentPresenter" Cursor="{TemplateBinding Cursor}" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="{TemplateBinding Padding}"/>
                    <Rectangle Grid.Column="1" Fill="#FFE9EEF4" Grid.Row="1"/>
                    <ScrollBar x:Name="VerticalScrollBar" Grid.Column="1" IsTabStop="False" Maximum="{TemplateBinding ScrollableHeight}" Margin="0,-1" Minimum="0" Orientation="Vertical" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" Width="18"/>
                    <ScrollBar x:Name="HorizontalScrollBar" Grid.Column="0" Height="18" IsTabStop="False" Maximum="{TemplateBinding ScrollableWidth}" Margin="-1,0,-1,-1" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{TemplateBinding HorizontalOffset}" ViewportSize="{TemplateBinding ViewportWidth}"/>
                   </Grid>
                  </Grid>
                 </ControlTemplate>
                </Setter.Value>
               </Setter>
              </Style>
             </Border.Resources>
             <Grid>
              <Grid.RowDefinitions>
               <RowDefinition Height="*"/>
               <RowDefinition Height="Auto"/>
              </Grid.RowDefinitions>
              <ScrollViewer Background="{x:Null}" IsTabStop="False" Padding="{TemplateBinding Padding}" Style="{StaticResource CustomScrollViewerStyle}" VerticalScrollBarVisibility="Auto">
               <ContentPresenter x:Name="ContentPresenter" Margin="12,12,6,12"/>
              </ScrollViewer>
              <Grid Margin="0,8,0,8" Grid.Row="1">
               <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
               </Grid.ColumnDefinitions>
               <Button x:Name="CommitButton" Content="{TemplateBinding CommitButtonContent}" Grid.Column="1" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,0,12,0" MinWidth="75" MinHeight="22" Style="{TemplateBinding CommitButtonStyle}" Visibility="Collapsed" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
              </Grid>
             </Grid>
            </Border>
           </ControlTemplate>
          </Setter.Value>
         </Setter>
        </Style>
0 Kudos
DonFreeman
Emerging Contributor
debroux -
Thanks, but Wow. That's not what I expected and I'm not sure it will get me to where I need to be. I need to be able to dynamically specify which fields are available to which users and which fields are editable, and maybe even turn a label within the dataform on and off. So maybe my original question was misguided. How would you do these things? Can they be done with a style?

I was thinking more along the lines of
<FeatureDataform.EditTemplate>
  <Label><textbox>
     <button>
etc.
0 Kudos