Select to view content in your preferred language

How to add a cancel button in FeatureDataForm?

858
6
11-02-2010 06:48 AM
XiujuZhou
Emerging Contributor
I need to add a button  in FeatureDataForm in order to cancel the graphic just added on graphic layer. Is that possible and how to add it in Expression Blend?
0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor
Here's a blog on how you can customize the look and feel of ArcGIS controls http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2010/05/20/Use-control-templates-to-customize...

It's similar steps except you choose FeatureDataForm
0 Kudos
XiujuZhou
Emerging Contributor
Thanks Jennifer. I still cannot add a button to it. the FeatureDataForm is kind of one control, the Apply button cannot be seen,  and my button cannot be inserted into FeatureDataForm.

Here's a blog on how you can customize the look and feel of ArcGIS controls http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2010/05/20/Use-control-templates-to-customize...

It's similar steps except you choose FeatureDataForm
0 Kudos
AliMirzabeigi
Emerging Contributor
Look for the following section of FeatureDataForm default control template. I have added a "CancelButton" on the left side of "CommitButton", i.e.

<Button x:Name="CancelButton" Content="Cancel" Grid.Column="0" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,0,12,0" MinWidth="75" MinHeight="22" Style="{TemplateBinding CommitButtonStyle}" Visibility="Visible" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
...
<Grid Height="166" Width="246">
<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="CancelButton" Content="Cancel" Grid.Column="0" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,0,12,0" MinWidth="75" MinHeight="22" Style="{TemplateBinding CommitButtonStyle}" Visibility="Visible" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
<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>...
0 Kudos
XiujuZhou
Emerging Contributor
Thank you Ali. I am wondering why my xaml code of FeatureDataForm copied from Resource center is just black box:
   <esri:FeatureDataForm x:Name="MyFeatureDataForm"   FeatureLayer="{Binding Path=Layers[PointLayer], ElementName=MyMap}"  IsReadOnly="False" LabelPosition="Left" />

How can I convert the code to be style like yours? then I can add the button.
0 Kudos
AliMirzabeigi
Emerging Contributor
You can use Expression Blend and right-click on your FeatureDataForm and select "Edit Template" --> "Edit a copy...", then you will get the default control template for your FeatureDataForm. Switch to the XAML view and look for the "CommitButton" button. Jennifer shared a very good URL on how to do the styling in Blend, you can also look into that page.
0 Kudos
XiujuZhou
Emerging Contributor
Thank you very much, Ali! the way you provide is great! that is what I am looking for.

You can use Expression Blend and right-click on your FeatureDataForm and select "Edit Template" --> "Edit a copy...", then you will get the default control template for your FeatureDataForm. Switch to the XAML view and look for the "CommitButton" button. Jennifer shared a very good URL on how to do the styling in Blend, you can also look into that page.
0 Kudos