Telerik Forums
UI for WPF Forum
1 answer
391 views

I'm making a custom behavior for Telerik's RadGridView.
When this behavior is attached and its `PropertyName` is set to same property as specified by
DataMemberBinding value of some of the GridViewCheckBoxColumn of the grid, then toggling the checkbox in that column will apply same checkbox state to all selected rows (but only to the same column).  

That happens in the `ApplyToAllSelected` method, namely in `gvcb.SetCurrentValue(GridViewCheckBox.IsCheckedProperty, isChecked);` line. The visuals are working as expected, and all checkbox values are updated on screen.

**The Problem** is that the binding source is not updated for those rows. Only for the one where click happened. `GridViewCheckBox.IsChecked` dependency property does not seem to be bound directly to the datacontext's property, so `gvcb.GetBindingExpression(GridViewCheckBox.IsChecked)` returns `null`.

**The Question**: how to update source after setting checkbox state?


```
public sealed class CheckAllSelectedBehavior : Behavior<RadGridView>
    {
        public event EventHandler Toggled;

        public string PropertyName { get; set; }

        protected override void OnAttached()
        {
            base.OnAttached();

            this.AssociatedObject.PreparingCellForEdit += this.AssociatedObject_PreparedCellForEdit;
            this.AssociatedObject.CellEditEnded += this.AssociatedObject_CellEditEnded;
        }

        protected override void OnDetaching()
        {
            this.AssociatedObject.PreparingCellForEdit -= this.AssociatedObject_PreparedCellForEdit;
            this.AssociatedObject.CellEditEnded -= this.AssociatedObject_CellEditEnded;
            base.OnDetaching();
        }

        private void AssociatedObject_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
        {
            if (e.Cell.Column.UniqueName == this.PropertyName && e.EditingElement is CheckBox cb)
            {
                cb.Checked -= this.Cb_Checked;
                cb.Unchecked -= this.Cb_Unchecked;
            }
        }

        private void AssociatedObject_PreparedCellForEdit(object sender, GridViewPreparingCellForEditEventArgs e)
        {
            if (e.Column.UniqueName == this.PropertyName && e.EditingElement is CheckBox cb)
            {
                cb.Checked += this.Cb_Checked;
                cb.Unchecked += this.Cb_Unchecked;
            }
        }

        private void Cb_Unchecked(object sender, System.Windows.RoutedEventArgs e)
        {
            this.ApplyToAllSelected(false);
        }

        private void Cb_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            this.ApplyToAllSelected(true);
        }

        private void ApplyToAllSelected(bool isChecked)
        {
            foreach (var item in this.AssociatedObject.SelectedItems)
            {
                var row = this.AssociatedObject.GetRowForItem(item);
                var cell = row.GetCellFromPropertyName(this.PropertyName);
                if (cell.Content is GridViewCheckBox gvcb)
                {
                    gvcb.SetCurrentValue(GridViewCheckBox.IsCheckedProperty, isChecked);
                }
            }

            this.Toggled?.Invoke(this, EventArgs.Empty);
        }
    }
```

This is a copy of [StackOverflow Thread](https://stackoverflow.com/questions/62192784/programatically-change-state-of-gridviewcheckboxcolumn-row-with-updating-binding)

Petar Mladenov
Telerik team
 answered on 11 Jun 2020
2 answers
728 views

Very simple question. How do I statically change content? I figured something like this example:

 

01.<telerik:RadNavigationView HorizontalAlignment="Stretch" PaneHeader="Header" VerticalAlignment="Stretch">
02.            <telerik:RadNavigationView.Items>
03.                <telerik:RadNavigationViewItem Content="Navigation item 1">
04.                    <StackPanel>
05.                        <Label Content="Test 1"/>
06.                    </StackPanel>
07.                </telerik:RadNavigationViewItem>
08.                <telerik:RadNavigationViewItem Content="Navigation item 2">
09.                    <StackPanel>
10.                        <Label Content="Test 2"/>
11.                    </StackPanel>
12.                </telerik:RadNavigationViewItem>
13.                <telerik:RadNavigationViewItem Content="Navigation item 3">
14.                    <StackPanel>
15.                        <Label Content="Test 3"/>
16.                    </StackPanel>
17.                </telerik:RadNavigationViewItem>
18.            </telerik:RadNavigationView.Items>
19.        </telerik:RadNavigationView>

 

But it doesn't work, saying that content is set multiple times.


Martin
Top achievements
Rank 1
Veteran
 answered on 10 Jun 2020
1 answer
358 views
Hi,
we got stuck in what might be an issue with your RadSpreadsheet.
We use the control to show a read-only imported file on our WPF client, full of numbers and formulas.
The problem arises when window (the operating system) regional settings (ex. USA, Italy, or any country) and advanced settings are incoherent such that the country has x as decimal separator culture and y as group separator culture and, in advanced settings, inverted values are provided (y as decimal separator and x as group separator). For example, this happens if we set Usa and "," as decimal separator and "." as group separator, or Italy and "." as decimal separator and "," as group separator.
What happens is that, although the values stored in any cell are correct if retrieved via code, the final rendering shows wrong decimal numbers and it seems that the decimal separator is considered as a group separator. For example, if the value would be 0.00, with the incoherent configuration above the value shown by the control would be 000.
Thanks

Nikolay Demirev
Telerik team
 answered on 10 Jun 2020
10 answers
193 views

Hello,

I have a .NET Core WPF application with the following statement as the first statement of the application:

RadRibbonWindow.IsWindowsThemeEnabled = false;

 

(without this statement, the display is ugly when the application is in full screen, as you can see in your own Report Designer...)

The problem is that, when the application is in full screen mode, it seems that the ribbon is too wide: the first icon at left is near the window edge and the minimize button at the right is partially hidden.

This doesn't appear with the Office2013 theme.

 

Vladimir Stoyanov
Telerik team
 answered on 10 Jun 2020
0 answers
217 views

I have created a radcombobox inside my radgridview and bound some text to it which works fine, but I can't seem to get it to update the database for the selected row when I change the selection of the combo box?

 

My XAML:

<telerik:GridViewDataColumn Header="Produktgruppe" Width="Auto" MinWidth="180" IsReadOnly="True">
                    <telerik:GridViewDataColumn.CellStyle>
                        <Style TargetType="{x:Type telerik:GridViewCell}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type telerik:GridViewCell}">
                                        <telerik:RadComboBox ItemsSource="{Binding Source={StaticResource ViewModelProductGroups}, Path=ProductGroups}"
                                                             DisplayMemberPath="Name"
                                                             IsEditable="True"
                                                             IsReadOnly="True"
                                                             SelectedIndex="0"
                                                             EmptyText="Vælg produktgruppe"/>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </telerik:GridViewDataColumn.CellStyle>
                </telerik:GridViewDataColumn>

 

My code-behind:

public Products()
        {
            InitializeComponent();
        }
 
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            using (Context dbContext = new Context())
            {
                GvProducts.ItemsSource = dbContext.Product.Include(x => x.ProductGroup).ToList();
            }
        }
 
        private void GvProducts_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
            if (e.NewData is Models.Product editedProduct)
            {
                using (Context dbContext = new Context())
                {
                    dbContext.Entry(editedProduct).State = EntityState.Modified;
                    dbContext.SaveChanges();
                }
            }
        }

 

My view model

sdf

public ObservableCollection<Models.ProductGroup> ProductGroups { get; set; }
        public ViewModelProductGroups()
        {
            using (Context dbContext = new Context())
            {
                ProductGroups = new ObservableCollection<Models.ProductGroup>(dbContext.ProductGroup.ToList());
            }
        }

 

Any suggestions?

Martin
Top achievements
Rank 1
Veteran
 asked on 10 Jun 2020
2 answers
482 views

I have a weird problem with a RadWIndow that is to replace the regular Window.

It's showing inside what appears to be a browser and I have no idea how to fix this.

 

Any ideas?

 

MainWindow.xaml

<telerik:RadWindow x:Class="TelerikWpfApp1.MainWindow"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                   Width="1200" Height="850" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen" MinWidth="1200" MinHeight="850" CaptionHeight="25" IsRestricted="True">
    <telerik:RadWindow.Resources>
        <telerik:StringToGlyphConverter x:Key="StringToGlyphConverter" />
        <telerik:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
        <Style x:Key="ItemPreviewStyle" TargetType="telerik:RadNavigationViewItem">
            <Setter Property="IconTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <telerik:RadGlyph Glyph="{Binding Converter={StaticResource StringToGlyphConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ItemBaseStyle" TargetType="telerik:RadNavigationViewItem" BasedOn="{StaticResource ItemPreviewStyle}">
            <Setter Property="Content" Value="{Binding Title}" />
            <Setter Property="ItemsSource" Value="{Binding SubItems}"/>
            <Setter Property="Icon" Value="{Binding Icon}" />
            <Setter Property="IconVisibility" Value="{Binding Icon, Converter={StaticResource NullToVisibilityConverter}}"/>
        </Style>
        <Style x:Key="ItemStyle" TargetType="telerik:RadNavigationViewItem" BasedOn="{StaticResource ItemBaseStyle}">
            <Setter Property="ItemContainerStyle" Value="{StaticResource ItemBaseStyle}"/>
        </Style>
    </telerik:RadWindow.Resources>
    <telerik:RadNavigationView x:Name="NavigationView" ItemsSource="{Binding Items}"
                               ItemContainerStyle="{StaticResource ItemStyle}"
                               AutoChangeDisplayMode="True"
                               DisplayMode="Expanded"
                               AllowMultipleExpandedItems="True"
                               SubItemsIndentation="40"
                               telerik:AnimationManager.IsAnimationEnabled="True"
                               Loaded="OnNavigationViewLoaded"
                               SelectionChanged="OnNavigationViewSelectionChanged">
        <Frame x:Name="frm"/>
    </telerik:RadNavigationView>
</telerik:RadWindow>

Martin
Top achievements
Rank 1
Veteran
 answered on 10 Jun 2020
5 answers
379 views
hi,
          I want to create password box inside rad grid view.it will display value from database to rad grid.also add grid to database.
that is two way binding.pls attach sample code. i already waste more time for searching.
Martin Ivanov
Telerik team
 answered on 09 Jun 2020
7 answers
217 views

Hello,

We're working on a WPF application that use Telerik wpf UI component version 2012.1.0326.40. 

So we wonder if you could easily upgrade to the lastest  WPF version?

Regards 

Yoan
Telerik team
 answered on 09 Jun 2020
4 answers
854 views

Hello,

I have a RadGridVeiw table with some values, i need to update certain cell values when the user clicks a button.

So far i have:

 

var column = TableGridView.CurrentCell.Column;
 
TableGridView.BeginEdit();
TableGridView.CurrentCell.Value = "test";
TableGridView.Rebind();

 

The value is updated in terms of code, but visually my Radgridview displays the old value.

 

can anyone help me?

 

 

Vadim
Top achievements
Rank 1
Veteran
 answered on 09 Jun 2020
2 answers
125 views

I have followed the advice on this forum post below by adding and removing a dummy object in my collection.

https://www.telerik.com/forums/force-filtering-to-refresh-when-values-in-existing-rows-are-updated#wbilJhXXv02aibtG_c5tTQ

This will force a RadGrid to show data that meets the filters criteria after the filter has been applied.

Unfortunately this breaks my cell flashing user control, which relies upon FrameworkElement.IsLoaded being true but is always false when doing the suggested fix from the forum post.

This is because the user control now being instantiated in CreateCellElement on each update rather than being reused.

How can I send a sample project? You can see when you run the solution, if you filter on the InAuction column and set it to true, you will see the rows being added but no cell flashing for the StockPrice column.

How can I fix the issue?

Martin Ivanov
Telerik team
 answered on 08 Jun 2020
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?