Telerik Forums
UI for WPF Forum
1 answer
192 views

Programmatically i'm selecting cells in RadGridView based on row and column. Search is done by column name and cell value. Grid records binded to the model by record properties. In my case column name could be different from record' property name, ex. translated to another language. Im wonder if there are a way to handle internaly record's column names but show on the grid custom names instead?

Binding is done by behavior:RadGridCustomBindingBehavior.Columns="{Binding GridColumns}", so [DisplayName("CustomColumnName")] is not applyed to the grid

Thank you

Martin Ivanov
Telerik team
 answered on 03 Apr 2023
0 answers
137 views
I see documentation for how to create a custom tagger, I'm just curious if anyone on the forums has already started one for Markdown syntax?
Joshua
Top achievements
Rank 2
 asked on 03 Apr 2023
0 answers
113 views

I feel that this is probably a property somewhere but I can't seem to find it.
I'm using RadDocking and I can drag a tab away so that it is floating.

When I'm dragging it back I only want to be able to drag it to the tabs area (centre of the compass)
I'm guessing that there's a property to stop/block a pane being dropped at the left, top, right or bottom.

What is the property that I'm missing?

I've tried IsLeftIndicatorVisible but it still shows a drop location at the left of the pane (hides it on the compass only)

Thanks

Paul
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 31 Mar 2023
0 answers
136 views

Hi,

Maybe I found a strange bug in RadListBox (2023 R1). I guess it is very hard to reply because I use it in a very complex way but maybe you could figure out the cause of problem.
My radlistbox is bound to a ObservableCollection of objects (we can name it List), and it is refreshed every time the user change the tab in raddocking. RadListbox is only one, while tab is multiple. It works in this context.

In my application I can "close the project", operation that implies the reset of every controls in the window, List is now clear, but the instance is still live.
I can "reopen the project" and the original tabs. In this context in many combination of tab open and close I get the following exception:

NsModules.App::AppDomainUnhandledException - System.ArgumentException: An item with the same key has already been added. Key: DeltaOhm.NsModules.Model.NsCursor
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Telerik.Windows.Automation.Peers.RadListBoxAutomationPeer.CreateItemAutomationPeer(Object item)
   at System.Windows.Automation.Peers.ItemsControlAutomationPeer.GetChildrenCore()
   at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
   at System.Windows.Automation.Peers.ItemsControlAutomationPeer.UpdateChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.ContextLayoutManager.fireAutomationEvents()
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at NsModules.App.Main()

I replaced RadListBox with system ListBox and the problem disappeared

Thank you

Luigi

Luigi
Top achievements
Rank 3
Bronze
Iron
Iron
 updated question on 31 Mar 2023
1 answer
429 views

I have a GridViewDataColumn and I want to add a filter option to this column.

The value of this column is if of type enum.

I would appreciate help with how to add filtering to this column.

<telerik:GridViewDataColumn Header="Status" CellStyle="{StaticResource StatusCellStyle}"/>

        <Style x:Key="StatusCellStyle" TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <TextBlock Text="{Binding Status}" >
                            <TextBlock.Style>
                                <Style TargetType="TextBlock">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Status}" Value="{x:Static Status.Completed}">
                                            <Setter Property="Foreground" Value="Green"/>
                                        </DataTrigger>

                                        <DataTrigger Binding="{Binding Status}" Value="{x:Static Status.Pending}">
                                            <Setter Property="Foreground" Value="Red"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
Stenly
Telerik team
 answered on 31 Mar 2023
1 answer
457 views

Hi, 

I am using a RadGridView to bind a DataTable. In that table I have dynamically generated columns. That's why I chose to set AutoGenerateColumns=true. 

I am now looking for a way to style the cells in depending on the properties of the object within the cell of the DataTable.

What I tried until now:

The first method seem the most promissing to me, so here is some code for that:


<UserControl.Resources>
        <Style x:Key="PilotStyle"
               TargetType="telerik:GridViewCell">
            <Setter Property="Background"
                    Value="Magenta" />
        </Style>
        <Style x:Key="ExpansionStyle"
               TargetType="telerik:GridViewCell">
            <Setter Property="Background"
                    Value="Aqua" />
        </Style>
        <valueConverters:RodTimeTypeConverter x:Key="converter" />
        <local:RodTableCellStyleSelector x:Key="selector"
                                         ConditionConverter="{StaticResource converter}">
            <local:RodTableCellStyleSelector.Rules>
                <local:ConditionalStyleRule Style="{StaticResource PilotStyle}">
                    <local:ConditionalStyleRule.Value>
                        <system:Boolean>True</system:Boolean>
                    </local:ConditionalStyleRule.Value>
                </local:ConditionalStyleRule>
                <local:ConditionalStyleRule Style="{StaticResource ExpansionStyle}">
                    <local:ConditionalStyleRule.Value>
                        <system:Boolean>False</system:Boolean>
                    </local:ConditionalStyleRule.Value>
                </local:ConditionalStyleRule>
            </local:RodTableCellStyleSelector.Rules>
        </local:RodTableCellStyleSelector>
    </UserControl.Resources>


<telerik:RadGridView  Grid.Row="1"
                                  CanUserSortColumns="False"
                                  CanUserSelectColumns="False"
                                  CanUserReorderColumns="False"
                                  CanUserDeleteRows="False"
                                  CanUserGroupColumns="False"
                                  CanUserSelect="False"
                                  IsFilteringAllowed="False"
                                  ShowColumnSortIndexes="False"
                                  ShowGroupPanel="False"
                                  RowHeight="45"
                                  AutoGeneratingColumn="GridViewDataControl_OnAutoGeneratingColumn"
                                  ItemsSource="{Binding RodTimesTable.DefaultView}">
                <telerik:RadGridView.Resources>
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="FontSize"
                                Value="20" />
                    </Style>

                </telerik:RadGridView.Resources>
            </telerik:RadGridView>


public class RodTableCellStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            var conditionValue = this.ConditionConverter.Convert(item, null, null, null);
            foreach (var rule in this.Rules.Where(rule => Equals(rule.Value, conditionValue)))
            {
                return rule.Style;
            }

            return base.SelectStyle(item, container);
        }

        List<ConditionalStyleRule> rules;
        public List<ConditionalStyleRule> Rules
        {
            get
            {
                return this.rules ??= new List<ConditionalStyleRule>();
            }
        }

        public IValueConverter ConditionConverter { get; set; }
    }
    public class ConditionalStyleRule
    {
        public object Value { get; set; }

        public Style Style { get; set; }
    }



private void GridViewDataControl_OnAutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
        {
            var grid = (RadGridView)sender;
            var dataGrid = (grid.ItemsSource as DataView)?.Table;
            e.Column.Header = dataGrid?.Columns[e.Column.Header.ToString()].Caption;
            if (e.Column.Header != null && (e.Column.Header.ToString().StartsWith("Pilot") || e.Column.Header.ToString().StartsWith("Expansion")) )
            {
                e.Column.CellStyleSelector = (StyleSelector)this.FindResource("selector");
            }
        }

I would really appreciate any help.

 

Thanks in advance.

Stenly
Telerik team
 answered on 31 Mar 2023
1 answer
100 views

Hi,

What I'm tryin to do is create an App that starts hidden (without a RadWindow) and when you click on a context menu of NotifyIcon it shows a RadWindow. I've tried several options and none work correctly.

What would be the best approach for this scenario?

 

Thanks

Martin Ivanov
Telerik team
 answered on 30 Mar 2023
0 answers
109 views
We are using RadSemicircleNorthGauge and RadProgressBar, and we would like to update the look and feel, but I don't really know what changes have been made since 2017.   Perhaps there are new controls we should use or updated properties on the existing ones.  Can you point me to the right place to get this information?
Brett
Top achievements
Rank 1
 asked on 29 Mar 2023
1 answer
312 views

In my MainWindow I am using a RadDocking container for displaying 3 RadSplitContainer. My problem is that I cannot set the size of those RadSplitContainers correctly.

I set the HasDocumentHost property of the RadDocking to False.

I tried setting the ProportionalStackPanel.RelativeSize property on each of my RadPaneGroups. These settings get completely ignored.

Here is my MainWindow.xaml code:


<DockPanel>
        <views:MenuBarView DataContext="{Binding MenuBar}" DockPanel.Dock="Top"/>
        <telerik:RadDocking Name="radDocking" HasDocumentHost="False">
                <telerik:RadSplitContainer HorizontalContentAlignment="Stretch"
                                        InitialPosition="DockedLeft">
                    <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="200,600">
                        <telerik:RadPane Header="{helpers:SwitchBinding DirtyBit, Pages*, Pages}" telerik:RadDocking.SerializationTag="PagesPane"
                                        CanUserClose="False" CanUserPin="False" >
                            <views:PagesView DataContext="{Binding PagesViewModel}" />
                        </telerik:RadPane>
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
                <telerik:RadSplitContainer InitialPosition="DockedTop">
                    <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="400,400">
                        <telerik:RadPane Header="{helpers:SwitchBinding DirtyBit, Editor*, Editor}" Name="MainEditor"
                                    CanUserClose="False" CanUserPin="False">
                            <views:EditorView DataContext="{Binding Editor}" />
                        </telerik:RadPane>
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
                <telerik:RadSplitContainer InitialPosition="DockedBottom">
                    <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="400,200">
                        <telerik:RadPane Header="Info" Name="Output" CanUserClose="False" CanUserPin="False">
                            <views:InfoView DataContext="{Binding InfoViewModel}"/>
                        </telerik:RadPane>
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
        </telerik:RadDocking>
    </DockPanel>

The result looks something like shown in MainWindow_Layout.PNG. But I would like a layout (and I would have guessed that my ProportionalStackPanel.RelativeSize properties set this behavior) like the one shown in MainWindow_Layout_desired.PNG.

How can I set the RadSplitContainers' relative size correctly?

Philipp
Top achievements
Rank 1
Iron
 answered on 29 Mar 2023
1 answer
224 views

Today I tried to put a context menu on a row in a RadGridView that would operate on the row clicked.  I was surprised to find it was not nearly as trivial as I expected.  All the documentation on this is either very old or accomplishing it via code or code-behind.  The "official" demo even has an entry for "Row Context Menu", which sounds tantalizingly close until one looks at the code.  It's certainly not MVVM!

This should be as simple as the following:

<telerik:RadGridView ItemsSource="{Binding Path=MyRecords}">
    <telerik:RadContextMenu.ContextMenu>
        <telerik:RadContextMenu >
            <telerik:RadMenuItem Header="Do something to this record" Command="{Binding MyRowCommand}" CommandParameter="{Binding ?????}" />
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
	...
</telerik:RadGridView>

The problem is that I can't for the life of me figure out what to pass as the command parameter that will help me identify the row.

Any help would be much appreciated!

Martin Ivanov
Telerik team
 answered on 29 Mar 2023
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?