Select to view content in your preferred language

Questions about making view only Attachment Editor and Featrue data Grid

859
3
10-29-2010 04:44 AM
WilliamDonahue
Emerging Contributor
Hey Guys,

I'm trying to create a view only app using silverlight. Is there some way for me to diable the add attachment ability from the editor or just view the attributes without edits in the Data form grid.
0 Kudos
3 Replies
AliMirzabeigi
Emerging Contributor
Use the "IsReadOnly" attribute of the FeatureDataGrid to make it a view-only control in your application. For AttachmentEditor there is no specific property in regards to this and you should change its default control template to collapse the visibility of "Add" button (or alternatively remove it from your control).
0 Kudos
tomw
by
Emerging Contributor
it would be great if you could show how to hide this add button, thanks.
0 Kudos
JoeHershman
MVP Alum
The toolkit is an open source project available on codeplex, took this out of the style for the AttchmentEditor and commented out the button.  Placed it in the resources section of my control that has the AttachmentEditor


        <ControlTemplate x:Name="NoButtonTemplate" TargetType="esri:AttachmentEditor">
            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="BusyStates">
                        <VisualState x:Name="Loaded">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ProgressIndicator">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Busy">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ProgressIndicator">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation Duration="0:0:0.75" RepeatBehavior="Forever" To="360" Storyboard.TargetName="ProgressIndicator" 
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid Background="{TemplateBinding Background}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid x:Name="ProgressIndicator" Background="Transparent" Grid.Row="0" Grid.Column="0" Margin="3,0" 
                                  Visibility="Collapsed" HorizontalAlignment="Left" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <RotateTransform />
                        </Grid.RenderTransform>
                        <Ellipse Fill="#1E525252" Margin="11,2,11,20" Width="2" Height="2"/>
                        <Ellipse Fill="#3F525252" Height="3" Width="3" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,4,5,0" />
                        <Ellipse Fill="#7F525252" Width="4" HorizontalAlignment="Right" Height="4" VerticalAlignment="Top" Margin="0,9,1,0" />
                        <Ellipse Fill="#BF525252" Height="5" Width="5" VerticalAlignment="Bottom" Margin="0,0,3,3" HorizontalAlignment="Right" />
                        <Ellipse Fill="#FF525252" Height="6" Width="6" VerticalAlignment="Bottom" Margin="9,0" />
                    </Grid>
                    <!--<Button x:Name="AddNewButton" Content="Add" HorizontalAlignment="Right" 
                                    Margin="3" Padding="3" MinWidth="50" Grid.Row="0" Grid.Column="1" IsEnabled="False" />-->
                    <ScrollViewer Grid.Row="1" Margin="3,0,3,3" Grid.ColumnSpan="2">
                        <ItemsControl x:Name="AttachmentList" ItemTemplate="{TemplateBinding ItemTemplate}"/>
                    </ScrollViewer>
                </Grid>
            </Border>
        </ControlTemplate>




Added this code into the constructor of my control that has the AttachmentEditor on it.


            InitializeComponent();
            ControlTemplate ct = this.Resources["NoButtonTemplate"] as ControlTemplate;
            if ( ct == null ) return;


            AttachEditor.Template = ct;



No more button! 🙂

Good luck
Thanks,
-Joe
0 Kudos