I'm using the folowing xaml to bind both controls in order to update/delete the Grid selected item's:
<UserControl x:Class="SGA.UserControls.manFormasContacto"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:vm="clr-namespace:SGA.ViewModels"
xmlns:swi="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:esi="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="600">
<UserControl.DataContext>
<vm:manFormasContactoVM/>
</UserControl.DataContext>
<Grid x:Name="LayoutRoot" Width="600" Height="400">
<Border CornerRadius="10" Background="Gray">
<Border CornerRadius="9" Background="#FFCCCCCC" Margin="1">
<Border CornerRadius="5" Background="White" Margin="7">
</Border>
</Border>
</Border>
<Grid Name="GridInterna" Margin="10,10,10,10" >
<Grid.Resources>
<DataTemplate x:Key="Template">
<telerik:DataFormDataField Name="a" Label="Designação" DataMemberBinding="{Binding DesignacaoProp, Mode=TwoWay}"/>
</DataTemplate>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="200*" />
<RowDefinition Height="168*" />
</Grid.RowDefinitions>
<telerik:RadGridView x:Name="grdFormasContacto" ItemsSource="{Binding OCFormasContacto}"
IsFilteringAllowed="False" IsReadOnly="True" MaxHeight="200"
ShowGroupPanel="False" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed"
Cursor="Hand" Margin="0,0,0,0" SelectedItem="{Binding FormaContactoSeleccionada, Mode=TwoWay}"
>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding DesignacaoProp, Mode=TwoWay}" Header="Designacao" Width="1*"></telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<telerik:RadDataForm x:Name="frmFormasContacto" AutoGenerateFields="False" Header="" Grid.Row="1" Visibility="Visible"
ReadOnlyTemplate="{StaticResource Template}"
EditTemplate="{StaticResource Template}"
NewItemTemplate="{StaticResource Template}"
CommitButtonContent="Gravar"
CancelButtonContent="Cancelar"
CommandButtonsVisibility="Add,Edit,Delete,Commit,Cancel"
LabelPosition="Beside" ValidationSummaryVisibility="Visible"
UseLayoutRounding="True" FontFamily="Verdana" FlowDirection="LeftToRight"
DataContext="{Binding}" ItemsSource="{Binding OCFormasContacto}"
CurrentItem="{Binding SelectedItem, ElementName=grdFormasContacto, Mode=TwoWay}"
BorderThickness="1">
<swi:Interaction.Triggers>
<swi:EventTrigger EventName="AddingNewItem">
<esi:CallDataMethod Method="NovoElemento" />
</swi:EventTrigger>
<swi:EventTrigger EventName="DeletedItem">
<esi:CallDataMethod Method="ItemEliminado" />
</swi:EventTrigger>
<swi:EventTrigger EventName="DeletingItem">
<esi:CallDataMethod Method="ItemEmEliminacao" />
</swi:EventTrigger>
<swi:EventTrigger EventName="EditEnding">
<esi:CallDataMethod Method="ItemEmEdicao" />
</swi:EventTrigger>
<swi:EventTrigger EventName="EditEnded">
<esi:CallDataMethod Method="ItemEditado" />
</swi:EventTrigger>
</swi:Interaction.Triggers>
</telerik:RadDataForm>
<telerik:RadBusyIndicator Name="bsyIndicator" IsBusy="{Binding BloquearLeituraEscritaDados}"/>
<!--
<Button Name="Dummy" Content="B1" Visibility="{Binding MostraComponente}" Width="100" Height="40" />
<Button Name="Activator" Content="Click" Command="{Binding Comando}" Width="100" Height="40" Margin="200,0,0,0" Grid.Row="1" />
-->
</Grid>
</Grid>
</UserControl>
My problem happens when I have no items in the collection that feeds the GridView. Like that, the [Add] button from the DataForm turns disabled.
Note: When I have items to display in my GridView and delete them all, the [Add] button doesn't turn disabled.
I still have another question: how to change the the tooltips for [Add], [Edit] and [Delete] buttons in the DataForm?
16 Answers, 1 is accepted
Straight to the questions:
1.Thus button is disabled when the source collection does not allow adding items.
May you please share with us what type of collection do you use as ItemsSource for RadDataForm?
You should also have a parameterless constructor.
2. If you need to remove the tooltips you have to edit the template of DataFormDataField and remove its default tooltips, you may refer to the following help article.
Hope this helps!
Vanya Pavlova
the Telerik team
The collection that feeds the GridView is:
private ObservableCollection<FormasContacto> _ocFormasContacto;
public ObservableCollection<FormasContacto> OCFormasContacto
{
get
{
return _ocFormasContacto;
}
set
{
if (_ocFormasContacto != value)
{
_ocFormasContacto = value;
OnPropertyChanged("OCFormasContacto");
}
}
}
The FormasContacto Object is generated by the Telerik ORM and it has a parameterless contructor.
Just to make a detail more clear, please notice: When I delete all the items in the GridView, the button [Add] (correctly) does not turn disabled. But if I close the window and access to it again, with the itemless GridView, the DataForm turns the [Add] button disabled.
I've started an application using Telerik's ORM with oracle and after several rookie errors done by me it all came to function pretty well with the exception of one or another detail.
I also use the GridView wich is a pretty nice control. Full of enhancements, its a PRO product.
Now.. about the RadDataForm. Seems nice, looks nice, but in a professional context, in the place where I stand at the moment, doesn't seem developed enough to use in a production application. As an example, I can make an aproach to the CommandButtons [First]/[Previous/[Next]/[Last] - [Add]/[Edit]/[Delete] - [Save]/[Cancel].
1) I don't use the first 4 because my dataform is binded to a GridView. And the element navigation is set by the GridView's selected item. I've set them not to be shown. No problem here.
2) About the [Add] button, as I said before, if the data form is binded to a GridView and if that GridView has no elements:
2a) The button is shown if in the same page/usercontrol I delete every element in the GridView;
2b) The button is not shown if I navigate to that page/usercontrol afterwards; !PROBLEM!
3) When I click the [Edit] button, the [Add] and [Delete] buttons are still shown and enabled.. So this takes me to a complete Hell of state validations and even with those validations I get errors. It is impossible that my solution pass on my company's quality tests. The weird thing is that if I click the [Add] button, all of the buttons get (correctly) disabled - exception of [Save] and [Cancel] one's of course.
The problem is that I lost a lot of time getting my code in order to work with the DataForm control, and now I'm afraid it won't serve for anything and goes to garbage..
In your sincere opinion, do you guys think that this control is good enough to use in a professional application?
PS: In an hour from now, I'm invited to my chief's office in order to give the feedback of the doings in the project.. I think my head is going to roll!
The:
2) About the [Add] button, as I said before, if the data form is binded to a GridView and if that GridView has no elements:
2a) The button is shown if in the same page/usercontrol I delete every element in the GridView;
2b) The button is not shown if I navigate to that page/usercontrol afterwards; !PROBLEM!
Is still a big problem. Like that I just can't add any entities...
Regarding the Add button : Here are some details on the internal logic which might help you isolate the problem :
RadDataForm will show the Add button only if it is bound to a collection. It will not show the button if it is bound to a single object ( e.g. via the CurrentItem property) .
There is also an internal build coming today or tomorrow. It will have some improvements included , regarding the visibility of the Add button . You may wish to upgrade to the fresh binaries. I believe they will be available in your account for download later today or tomorrow.
All the best,
Pavel Pavlov
the Telerik team
Getting back to the tooltip problem...
I've only changed the Cursor Propriety from the [Add] button in order to get the local where those tooltips are defined. I've put to bold that single detail:
<Telerik_Windows_Controls_Data_DataForm:CollectionNavigator x:Name="CollectionNavigator" Grid.Row="1" telerik:StyleManager.Theme="{StaticResource Theme}">
<Telerik_Windows_Controls_Data_DataForm:CollectionNavigator.Resources>
<SolidColorBrush x:Key="NagigatorIconColor" Color="Black"/>
<ControlTemplate x:Key="CollectionNavigatorTemplate" TargetType="Telerik_Windows_Controls_Data_DataForm:CollectionNavigator">
<Border x:Name="PART_RootElement" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid x:Name="PART_CollectionNavigatorGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" HorizontalAlignment="Left" Orientation="Horizontal">
<telerik:RadButton x:Name="MoveCurrentToFirst" Command="controls:RadDataFormCommands.MoveCurrentToFirst" Height="18" Margin="4,4,2,4" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding NavigationButtonsVisibility}" Width="18">
<ToolTipService.ToolTip>
<ToolTip telerik:LocalizationManager.ResourceKey="DataForm_MoveCurrentToFirst" telerik:StyleManager.Theme="{StaticResource Theme}"/>
</ToolTipService.ToolTip>
<StackPanel Orientation="Horizontal">
<Rectangle Fill="{StaticResource NagigatorIconColor}" HorizontalAlignment="Center" Height="7" VerticalAlignment="Center" Width="1"/>
<Path Data="M0,0 L3.5,3.5 0,7 Z" Fill="{StaticResource NagigatorIconColor}" HorizontalAlignment="Center" Height="7" RenderTransformOrigin="0.5, 0.5" VerticalAlignment="Center" Width="4">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
<SkewTransform AngleY="0" AngleX="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</StackPanel>
</telerik:RadButton>
<telerik:RadButton x:Name="MoveCurrentToPrevious" Command="controls:RadDataFormCommands.MoveCurrentToPrevious" Height="18" Margin="2,4,2,4" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding NavigationButtonsVisibility}" Width="18">
<ToolTipService.ToolTip>
<ToolTip telerik:LocalizationManager.ResourceKey="DataForm_MoveCurrentToPrevious" telerik:StyleManager.Theme="{StaticResource Theme}"/>
</ToolTipService.ToolTip>
<Path Data="M0,0 L3.5,3.5 0,7 Z" Fill="{StaticResource NagigatorIconColor}" HorizontalAlignment="Center" Height="7" RenderTransformOrigin="0.5, 0.5" VerticalAlignment="Center" Width="4">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
<SkewTransform AngleY="0" AngleX="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</telerik:RadButton>
<telerik:RadButton x:Name="MoveCurrentToNext" Command="controls:RadDataFormCommands.MoveCurrentToNext" Height="18" Margin="2,4,2,4" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding NavigationButtonsVisibility}" Width="18">
<ToolTipService.ToolTip>
<ToolTip telerik:LocalizationManager.ResourceKey="DataForm_MoveCurrentToNext" telerik:StyleManager.Theme="{StaticResource Theme}"/>
</ToolTipService.ToolTip>
<Path Data="M0,0 L3.5,3.5 0,7 Z" Fill="{StaticResource NagigatorIconColor}" HorizontalAlignment="Center" Height="7" VerticalAlignment="Center" Width="4"/>
</telerik:RadButton>
<telerik:RadButton x:Name="MoveCurrentToLast" Command="controls:RadDataFormCommands.MoveCurrentToLast" Height="18" Margin="2,4,2,4" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding NavigationButtonsVisibility}" Width="18">
<ToolTipService.ToolTip>
<ToolTip telerik:LocalizationManager.ResourceKey="DataForm_MoveCurrentToLast" telerik:StyleManager.Theme="{StaticResource Theme}"/>
</ToolTipService.ToolTip>
<StackPanel Orientation="Horizontal">
<Path Data="M0,0 L3.5,3.5 0,7 Z" Fill="{StaticResource NagigatorIconColor}" HorizontalAlignment="Center" Height="7" VerticalAlignment="Center" Width="4"/>
<Rectangle Fill="{StaticResource NagigatorIconColor}" HorizontalAlignment="Center" Height="7" VerticalAlignment="Center" Width="1"/>
</StackPanel>
</telerik:RadButton>
</StackPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
<telerik:RadButton x:Name="AddNew" Command="controls:RadDataFormCommands.AddNew" Height="18" Margin="2,4,2,4" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding AddNewButtonVisibility}" Width="18" Cursor="Hand">
<ToolTipService.ToolTip>
<ToolTip telerik:LocalizationManager.ResourceKey="DataForm_AddNew" telerik:StyleManager.Theme="{StaticResource Theme}"/>
</ToolTipService.ToolTip>
<Path Data="F1M8.334,13.301L4.889,13.301L4.889,2.699L12.599,2.699L12.599,9.037L12.559,9.077L8.346,9.078L8.346,13.29z M13.74,9.442L13.74,1.602L3.747,1.602L3.747,14.397L8.784,14.397z" Fill="{StaticResource NagigatorIconColor}" Height="11" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Width="8">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="-1"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</telerik:RadButton>
<telerik:RadButton x:Name="BeginEdit" Command="controls:RadDataFormCommands.BeginEdit" Height="18" Margin="2,4,2,4" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding EditButtonVisibility}" Width="18">
<ToolTipService.ToolTip>
<ToolTip telerik:LocalizationManager.ResourceKey="DataForm_BeginEdit" telerik:StyleManager.Theme="{StaticResource Theme}"/>
</ToolTipService.ToolTip>
<Path Data="M3.6943,11.9199L4.1323,9.5549C4.1443,9.4019,4.1953,9.2459,4.2973,9.1289L9.4233,4.0049L11.8853,6.4669L6.7593,11.5919C6.7043,11.6469,6.4893,11.7749,6.4183,11.7869L4.0083,12.2339C3.7943,12.2749,3.6533,12.1349,3.6943,11.9199 M4.8903,11.4789L6.2383,11.2519L10.9273,6.5619L10.3673,6.0059L5.7093,10.6679L4.8153,9.7169L4.5693,11.1329C4.7253,11.1989,4.8253,11.3219,4.8903,11.4789 M12.4513,5.9019L9.9893,3.4399L10.7863,2.6439C11.0063,2.4229,11.3643,2.4229,11.5853,2.6439L13.2483,4.3069C13.4683,4.5269,13.4683,4.8849,13.2483,5.1059z" Fill="{StaticResource NagigatorIconColor}" Height="11" Stretch="Fill" Width="10"/>
</telerik:RadButton>
<telerik:RadButton x:Name="Delete" Command="controls:RadDataFormCommands.Delete" Height="18" Margin="2,4,4,4" Padding="0" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding DeleteButtonVisibility}" Width="19">
<ToolTipService.ToolTip>
<ToolTip telerik:LocalizationManager.ResourceKey="DataForm_Delete" telerik:StyleManager.Theme="{StaticResource Theme}"/>
</ToolTipService.ToolTip>
<Path Data="M1,3 L2,3 L2,9 L3,9 L3,3 L4,3 L4,9 L5,9 L5,3 L6,3 L6,9 L7,9 L7,3 L8,3 L8,10 L1,10 z M2,0 L7,0 L7,0.99999994 L9,0.99999994 L9,2 L0,2 L0,0.99999994 L2,0.99999994 z" Fill="{StaticResource NagigatorIconColor}" Height="11" Stretch="Fill" Width="9"/>
</telerik:RadButton>
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
<SolidColorBrush x:Key="DataForm_CollectionNavigator_Border" Color="#FF848484"/>
<LinearGradientBrush x:Key="DataForm_CollectionNavigatorBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="#FFCDCDCD" Offset="1"/>
<GradientStop Color="#FFCECECE" Offset="0.42"/>
<GradientStop Color="#FFAFAFAF" Offset="0.43"/>
</LinearGradientBrush>
<Style x:Key="CollectionNavigatorStyle1" TargetType="Telerik_Windows_Controls_Data_DataForm:CollectionNavigator">
<Setter Property="Template" Value="{StaticResource CollectionNavigatorTemplate}"/>
<Setter Property="BorderBrush" Value="{StaticResource DataForm_CollectionNavigator_Border}"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Background" Value="{StaticResource DataForm_CollectionNavigatorBackground}"/>
<Setter Property="BorderThickness" Value="0,0,0,1"/>
</Style>
</Telerik_Windows_Controls_Data_DataForm:CollectionNavigator.Resources>
</Telerik_Windows_Controls_Data_DataForm:CollectionNavigator>
So...
<ToolTip telerik:LocalizationManager.ResourceKey="DataForm_AddNew" telerik:StyleManager.Theme="{StaticResource Theme}"/>
is there a way I can change only those ResourceKeys? And/Or/How I can call that big chunk of xaml from the RadDataForm's in my Usercontrol? I don't want to include all that xaml in every user control where I use RadDataForms.
I am not sure what is the question in your last post . Are you trying to localize the tooltips of the buttons ?
If this is the question , I am sure we can think of some solution without having to paste so much XAML .
Please let me know what exactly you are trying to achieve, and I will prepare a small sample for you .
All the best,
Pavel Pavlov
the Telerik team
yes, I'm searching for the minimalistic aproach in order to change those tooltips. XAML or programatically.
Edited: And Cursor type also BTW.
Thanks
Thanks
Regarding the tooltips : The recommended approach is described in this help article.
And the minimalistic approach is to find the button via code and set the tooltip directly.
The same about the cursor .
In the attached project I have demonstrated how to set the property to the button directly.
Regards,
Pavel Pavlov
the Telerik team
We are using version 2012.2.715.1050.
Will it be possible to share a bit more details ? What is the type of data source RadDataForm is filled with ? What is the implementation of your business object ? Could you try reproducing the issue in our demos ?
Do you refer to 2012.2.725.205 version rather than 2012.2.715.1050 ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Maya,
I'd be happy to. The ItemsSource of the dataform is bound to an IEnumerable<T> where T is a complex object. The CurrentItem is bound to the same complex object. There is a bit of juggling because we also use a radGridView. The following process occurs
1. A user selects an item in the radGridView
2. Using MVVM, the setter of the radGridView SelectedItem instantiates a new object we'll call myCurrentlyEditableObject
3. After myCurrentlyEditableObject is instantiated, it's placed into a list we'll call myEditableItems
4. The dataform with this issue's itemsSource is bound to myEditableItems and the CurrentItem is bound to myCurrentlyEditableObject.
I know that's a lot of juggling but it use to work.
I could not replicate the bug in the demos.
I did mean 2012.2.725.205, thank you for that correction.
I have tried to reproduce the issue you reported, but still without any success. Could you take a look at the sample attached and let me know whether I am missing something ? Can you verify whether initially you can insert new items in the grid as well ? Am I missing something ?
Maya
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.