Telerik Forums
UI for WPF Forum
4 answers
200 views

Hello,

I'm having trouble to automatically expand all groups within a RadGridView. I set the AutoExpandGroups to true and also call the RadGridView's method ExpandAllGroups(). It does expand all the groups, but it also adds an unwanted white space to my grid, that vanishes after I manually collapse one of the groups.

I also tried to set the GroupRenderMode to Flat. It solves the white space issue, but it adds unwanted information to my groups' headers.

Is there a way to make it work properly?

 

*Telerik UI for WPF version 2015.3.930.45

Thanks in advance.

Stefan
Telerik team
 answered on 27 Jul 2016
3 answers
923 views

I'm trying to create a column with a delete button that the user will use to delete rows. I want to force the user to use this button when they want to delete a row.

These were my requirements

  1. Clicking the delete button deletes the row immediately
  2. Clicking Delete on the keyboard won't delete the row
  3. The user can't enter the delete row by clicking outside of the button or using Tab to move between cells

Things I've done so far

  1. Created the column with the button and bound it to RadGridViewCommands.Delete
  2. Used the PreviewKeyDown event to stop the row delete when the user clicks Delete on the keyboard
  3. Set TabStopMode="Skip" and IsReadOnly="true" on the column with the delete buttons to keep the use from entering the delete column

So far this works but I found two issues (possibly the same issue but may require different solutions)

  1. When I create a new row, I can't click the delete button
  2. If I edit the value in a cell, I can't click the delete button

I figured they may be the same issue because they both have to do with being in edit mode for a row.

 

Issue when creating a new row

I run my project, click the bottom of the grid to create a new row, then try clicking the delete button on that row. Nothing happens.

It probably doesn't make much sense to delete a row while it's being added so that may be why this doesn't work. If possible I would like the delete button to cancel adding the new row, so kind of like a delete. If this isn't possible, I would like to be able to hide the button when a new row is created so it's obvious to the user they can't click it.

 

Issue when editing a row

I run my project, double click in one of the cells to start editing the cell, the try clicking the delete button. Again, nothing happens. The cell being edited seems to lose focus and no longer shows the edit box but I can't click the delete button. To get the delete to work I have to single click into a different cell and then click the delete button.

 

I appreciate any help you can provided.

 

This is the XAML for MainWindow

<Window
    x:Class="TelerikWpfGridViewDeleteButton.MainWindow"
    xmlns:local="clr-namespace:TelerikWpfGridViewDeleteButton"
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525"
    DataContext="{StaticResource MyViewModel}">
 
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
     
    <Grid>
        <telerik:RadGridView
            Name="RadGridViewVariableCutOff"
            ItemsSource="{Binding GridRows}"
            Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
            GroupRenderMode="Flat"
            NewRowPosition="Bottom"
            ShowGroupPanel="False"
            RowIndicatorVisibility="Collapsed"
            CanUserFreezeColumns="False"
            AutoGenerateColumns="False"
            SelectionMode="Single"
            SelectionUnit="Cell"
            PreviewKeyDown="RadGridViewVariableCutOff_PreviewKeyDown">
 
            <telerik:StyleManager.Theme>
                <telerik:Office_SilverTheme/>
            </telerik:StyleManager.Theme>
 
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn
                    Header="First Value"
                    Width="1*"
                    DataMemberBinding="{Binding Path=FirstValue}"/>
 
                <telerik:GridViewDataColumn
                    Header="Second Value"
                    Width="1*"
                    DataMemberBinding="{Binding Path=SecondValue}"/>
 
                <telerik:GridViewDataColumn
                    Header=""
                    Width="26"
                    TabStopMode="Skip"
                    IsReadOnly="True"
                    CellStyle="{StaticResource TelerikNoCellPadding}">
 
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadButton
                                Template="{StaticResource FlatImageButton}"
                                Margin="0"
                                Command="telerikGrid:RadGridViewCommands.Delete"
                                CommandParameter="{Binding}">
                                <Image Source="Delete_WithPadding.png"/>
                            </telerik:RadButton>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
 
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
 
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>

 

This is the code behind for MainWindow

using System.Windows;
using System.Windows.Input;
 
namespace TelerikWpfGridViewDeleteButton
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
 
        private void RadGridViewVariableCutOff_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Delete) e.Handled = true;
        }
    }
}

 

This is my view model

using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
 
namespace TelerikWpfGridViewDeleteButton
{
    public class MyViewModel : INotifyPropertyChanged
    {
        private ObservableCollection<RowData> gridRows;
        public ObservableCollection<RowData> GridRows
        {
            get
            {
                if (gridRows == null)
                {
                    gridRows = new ObservableCollection<RowData>();
                    gridRows.Add(new RowData() { FirstValue = 1, SecondValue = 2 });
                    gridRows.Add(new RowData() { FirstValue = 3, SecondValue = 4 });
                    gridRows.Add(new RowData() { FirstValue = 4, SecondValue = 6 });
                }
 
                return gridRows;
            }
            set
            {
                gridRows = value;
                NotifyPropertyChanged();
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

 

This is the class used in the observable collection

namespace TelerikWpfGridViewDeleteButton
{
    public class RowData
    {
        public decimal FirstValue { get; set; }
        public decimal SecondValue { get; set; }
 
        public RowData()
        {
        }
    }
}

 

This is my resource dictionary

<ResourceDictionary
    xmlns:local="clr-namespace:TelerikWpfGridViewDeleteButton">
     
    <ControlTemplate x:Key="FlatImageButton" TargetType="{x:Type Button}">
        <Border x:Name="bdr_main" SnapsToDevicePixels="True" BorderThickness="1" CornerRadius="0" Background="White">
            <ContentPresenter RecognizesAccessKey="True"></ContentPresenter>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="bdr_main" Property="BorderBrush" Value="Black"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
 
    <Style x:Key="TelerikNoCellPadding" TargetType="{x:Type telerik:GridViewCell}">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
    </Style>
</ResourceDictionary>

 

And this is my App.xaml

<Application x:Class="TelerikWpfGridViewDeleteButton.App"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:TelerikWpfGridViewDeleteButton"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <local:MyViewModel x:Key="MyViewModel" />
    </Application.Resources>
</Application>

 

And I've attached the delete button image I used

Stefan
Telerik team
 answered on 27 Jul 2016
4 answers
251 views

Hi,

I'm searching a way to highlight all supported drop zone in a control, when a drag start (and of course reverse to normal when drag end)... and using MVVM.

Is there something already existing about this use case ?

Thanks !

Regards,

Lagrange
Top achievements
Rank 1
 answered on 26 Jul 2016
13 answers
189 views

Hi,

I want to achive that the nested RadGridView in my RadComboBox gets the focus when the ComboBox' DropDown is opened. For this I want the reference of the nested GridView but ComboBox.FindChildByType<RadGridView> doesn't work.

Here is the XAML Code of my ComboBox

<telerik:RadComboBox Name="cbMachineType" Text="{Binding Fleet}" Grid.Row="2" Grid.Column="2" IsEditable="True"
                     Width="150" Height="{Binding ActualHeight, ElementName=txtName}"
                      DropDownOpened="cbMachineType_DropDownOpened">
    <telerik:RadComboBox.Items>
        <telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem.Template>
                <ControlTemplate>
                    <telerik:RadGridView x:Name="gvMachineType" ShowGroupPanel="False" CanUserFreezeColumns="False" IsReadOnly="True" IsFilteringAllowed="False"
                                         SelectionMode="Single" RowIndicatorVisibility="Collapsed"
                                         SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadComboBox}},Path=DataContext.SelectedMachineType}"
                                         DataContext="{StaticResource MachineTypeViewModel}" ItemsSource="{Binding MachineTypes}"
                                         Width="{Binding Width, ElementName=cbMachineType}" Height="150" AutoGenerateColumns="False"
                                         SelectionChanged="gvMachineType_SelectionChanged">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn Width="*" Name="cSubDescription" Header="Beschreibung" DataMemberBinding="{Binding Type}"/>
                            <telerik:GridViewDataColumn Width="1*" Name="cSubFleet" Header="Flotte" DataMemberBinding="{Binding Fleet}"/>
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
                </ControlTemplate>
            </telerik:RadComboBoxItem.Template>
        </telerik:RadComboBoxItem>
    </telerik:RadComboBox.Items>
</telerik:RadComboBox>

How can I achive this?

 

Greetings

Alexander

Stefan Nenchev
Telerik team
 answered on 26 Jul 2016
2 answers
90 views

General description of the project:
In our project we load MVVM-Architectured windows using C# Reflection and put them onto a RadDockPanel, that way it corresponds with our high demands of flexibility, you can specify which windows you want to load when the program starts or afterwards and also close them mid run without affecting the rest of the loaded windows.

The problem: for some reason when we load MVVM-windows that contain the RadGridView controls, they don't update in accordance to their binded-source.

The attachment contains a very stripped down version of loading a window that contains both, a RadGridView and a regular Microsoft DataGrid both of which are bound to the the same property(ObservableCollection). While the DataGrid is updating on every new Item added, the RadGridView does not. Even when explicitly told to do so using the CollectionChaged event.

Also, there's an attached project (ModuleConsoleStarter) that simply runs the same window not loading it with Reflection. In that project both controls are updating perfectly in accordance with theirs source!

My network security provider doesn't allow me to upload files so here is a Google Drive link:

https://drive.google.com/folderview?id=0B2kbmdtjQ0m_X0Zxajk4bkpiSFk&usp=sharing

Pituah
Top achievements
Rank 1
 answered on 26 Jul 2016
1 answer
48 views

Hi,

I tried to use the WPF telerik demo code to load modules of my application as done with the demo but I had a problem when trying to navigate to an example exp1 twice, the second time I am not able to navigate, but when I navigate to another example exp2 then exp1, it works:

exp1 -> home -> exp1: bug during the second navigation.
exp1 -> home -> exp2 -> home -> exp1: no problem.

I thought that may be the problem is with selector object in "SelectorHelper" class.

Can you give me any explanation or ideas about this problem.

Thanks,

Georgi
Telerik team
 answered on 26 Jul 2016
1 answer
142 views

Hi and thanks in advance!

I have a two-part wpf window, RadGridView on left, RadTreeView on right like the "Tree to grid drag example".

I need to drag&drop items from grid to tree (tree must be an Idef0 tree so I need to implement some custom logic in GridViewDragDropBehavior and TreeViewDragDropBehavior to avoid drop in some cases and notify user updating the DragVisual during drag).

All DragDropManager events are fired correctly and a I use DataTemplate and DropIndicationDetails (like your example) to initialize the DragVisual inside OnDragInitialize and update it inside OnDragOver...and I can populate the tree.

But DragVisual is never visible and I don't know why!

Without DragVisual notification and update (made with binding on DropIndicationDetails) it's pretty impossibile to understand the drop position and then notify the user if the operation is possible or not.

I'm using no xaml binaries dll and in MainSkin.xaml I have a ResourceDictionary with the following

<ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/System.Windows.xaml"/>
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.xaml"/>
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Data.xaml"/>
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
    </ResourceDictionary.MergedDictionaries>

Please help!

Yana
Telerik team
 answered on 26 Jul 2016
14 answers
1.4K+ views
Trying to display a RadBusyIndicator in an WPF MVVM application however the control does not appear when IsBusy binding occurs.

Here is a portion of what is in the user control xaml...

<Grid>
  <telerik:RadBusyIndicator IsBusy="{Binding IsBusy}" Grid.Row="0" >
    <Grid>
      <StackPanel Margin="10,10,10,10">
          ...some content here...                 
      </StackPanel>
    </Grid>
  </telerik:RadBusyIndicator>
</Grid>

I bind the IsBusy to a property in my ViewModel, set the property to true, and then fire OnPropertyChanged to rebind the view. Unfortunately the BusyIndicator does not show.

Has anyone experienced this challenge before, and if so, what was done to resolve it?

I'll follow up this post with an example solution that recreates the problem. Until then, let me know if you have any insights into this.

Cheers, 

Paul
Rob
Top achievements
Rank 1
 answered on 26 Jul 2016
2 answers
81 views

I have read-only RadGridView columns displaying error messages.

They tend to be long, but due to the read-only attribute, I cannot navigate to the end of them.

Other than extending the column width, is there any way to navigate the whole cell width, or to set a wrapper property?

Dodd
Top achievements
Rank 1
 answered on 26 Jul 2016
2 answers
197 views

In my RadGridView I group data by two columns: first by column1 and then by column2. When I set ShowGroupFooters="true" I end up with two footers - one for column1 and another for column2. How can I hide footers for the nested groups (over column2) and leave only footers for the groups over column1?

thank you

Dmitriy
Top achievements
Rank 1
 answered on 25 Jul 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?