Telerik Forums
UI for WPF Forum
1 answer
197 views

I do not know if I have defined question correctly, sorry for my lack of experience. Application I work on have a TreeView that is connected to data source. Data is hierarchical. There are root element and every root element can have children. Any children can have multiple other children. I have figured out how to data bind and show hierarchical data. Problem is that I need to style treeview items. I have figured out how to set itemtemplate on root and children in xaml. But now I have two copies of item template. One in ItemTemplate and another in its's hierachical item template. But they are identical, as I understand MVVM this could be an issue when I try to implement something more complex. Is there some elegant way to have this defined in one place and then shared on item template root and then it's children?

Here is the code of my TreeView in XAML:

<HierarchicalDataTemplate x:Key="HostsTemplatekey" ItemsSource="{Binding Children}"  >
                <StackPanel Orientation="Horizontal"  telerik:RadContextMenu.ContextMenu="{StaticResource TreeViewContextMenu}" >
                    <iconPacks:PackIconFeatherIcons Kind="Trash2" Width="20" Height="20" Visibility="{Binding Converter={StaticResource FileTypeToIconPackVisibilityConverter}, ConverterParameter= 3}" />
                    <TextBlock Width="10" />
                    <Grid>
                        <TextBlock Text="{Binding cityname}" VerticalAlignment="Center" FontSize="{StaticResource BaseCaptionFontSize }" />
                    </Grid>
                </StackPanel>
 
                <HierarchicalDataTemplate.ItemTemplate>
 
                    <HierarchicalDataTemplate ItemsSource="{Binding Children}"  >
                        <StackPanel Orientation="Horizontal"  telerik:RadContextMenu.ContextMenu="{StaticResource TreeViewContextMenu}">
                            <iconPacks:PackIconFeatherIcons Kind="Trash2" Width="20" Height="20" Visibility="{Binding Converter={StaticResource FileTypeToIconPackVisibilityConverter}, ConverterParameter= 3}" />
                            <TextBlock Width="10" />
                            <Grid>
                                <TextBlock Text="{Binding cityname}" VerticalAlignment="Center" FontSize="{StaticResource BaseCaptionFontSize }" />
                            </Grid>
                        </StackPanel>
 
                    </HierarchicalDataTemplate>
                </HierarchicalDataTemplate.ItemTemplate>
            </HierarchicalDataTemplate>
             
             
                <telerik:RadTreeView
                            Name="dgCities" Margin="10"
                            ItemsSource="{Binding data.CitiesCollection}"
                            IsEditable="True"
                            ItemTemplate="{StaticResource HostsTemplatekey}"
                            SelectedItem="{Binding data.SelectedCity, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                            IsDragDropEnabled="True"
                            />

 

 

 

Vladimir Stoyanov
Telerik team
 answered on 20 May 2020
1 answer
180 views
In the native Microsoft.Win32.OpenFileDialog, there is a property called CheckFileExists, which can be set to false to allow you to choose a file that doesn't exist from the open dialog for being able to make new files. But RadOpenFileDialog seems to require a file to exist and I'm not seeing an equivalent for this in RadOpenFileDialog. Is there an equivalent or some way to get this behavior?
Dinko | Tech Support Engineer
Telerik team
 answered on 20 May 2020
1 answer
149 views

I have different shapes which I drag from toolbox to diagram.

For example:

-Shape.name1 

-Shape.name2

-Shape.name3

What I want to do is on the diagram:

Move Shape1 to shape 2. So, Shape 1 bottom is connected to shape 2 top. (without connectors)

Shape 3 top should be only allowed to dock on shape 2 bottom.

All shapes have the same size.

Can anybody provide me some code examples for this?

fewfew
Top achievements
Rank 1
 answered on 20 May 2020
32 answers
1.1K+ views
Hello,

How can I get hold of a reference to the Filter popup and the Filter button? The reason I need this is that I want to respond to the click event of the button by closing the Filter popup.

I do not want to use the Filtered event on the RadGridView as that one is raised even when clicking on the check boxes.

I suppose using FindName on the Template would get the job done, but what is the template name for Filter popup?

Thank you.
Dinko | Tech Support Engineer
Telerik team
 answered on 20 May 2020
2 answers
147 views

I have  a Telerik gridview, with visible columns, works fine.  I now want to add column groups as in the example on

https://docs.telerik.com/devtools/wpf/controls/radgridview/columns/column-groups

 

But when I added columngroups-tag and some column groups, it results in a grid with only the column groups as headers and

the real column headers are gone. See attachment for my markup

Robert
Top achievements
Rank 1
Veteran
 answered on 19 May 2020
2 answers
129 views

Hi,

 

i grabbed the telerik editor and used in my WPF application, now i need to blink in red when the user exceeds the character length, but i'm unable to accomplish that, i can't even change the borderbrush of the RadRichTextBox that is within the Telerik Editor.

 

 

any suggestion?

 

 

regards.

 

 

Maximiliano
Top achievements
Rank 1
Veteran
 answered on 19 May 2020
4 answers
667 views

Sorry for posting 2 different issues in one thread, but they are kinda intertwined in my situation here.

The first thing I'm wanting to do is make it so the Enter key within the RadGridView is treated like the Tab key instead. I was able to successfully do this via a custom KeyboardCommandProvider, by making it call DefaultKeyboardCommandProvider's ProvideCommandsForKey with Key.Tab is the key was Key.Enter.

The second thing I'm wanting to do is specially handle what happens with new rows. There are 3 columns in the grid and the first 2 are being validated via INotifyDataErrorInfo while the last has no validation. I'm wanting to do the following with a new row:

  • On starting the new row, the first column is always selected. (I was able to do this without issues inside the AddingNewDataItem event, so this isn't a problem.)
  • On attempting to leave the first cell, I want to check the value and prevent progression if that value exists elsewhere in the same column. (I was able to do this without issues inside the CellValidating event, so this isn't a problem either.)
  • When pressing Enter or Tab in the last column, I want to get out of edit mode, select the new row after it has been added to the grid, and then scroll down to that new row. (This is where I am having all my issues, as I'll explain further below.)

What I've tried doing is inside of my custom KeyboardCommandProvider, if the key is Key.Tab or Key.Enter, Shift isn't being held down, and if I am in the last column (checking the grid's current column DisplayIndex and checking if it is 2) and in a new row (which I check by seeing if my view model's current selection is null, which I set inside the AddingNewDataItem event), then I was trying to remove the default actions of select current unit and begin edit (so the only action left is move next) and add in a custom command to attempt to select the new row (which I've stored inside of the RowEditEnded event).

My custom command for attempting the new row selection consists of canceling the grid view's edit, setting the CurrentCellInfo of the grid to the new item in the first column, and then using ScrollIntoViewAsync for the same item and column.

The issues I'm running in to:

  • I originally was not removing Tab's default commands or calling my custom command, and instead was trying to do the above stuff from the custom command within the SelectionChanged event. As I was storing the row inside the RowEditEnded event, I was also trying to change the current selected item in my view model through that event, which meant that running the commands in SelectionChanged only partially worked because the rest of the grid view's code for the RowEditEnded event after my callback would change the CurrentCellInfo.
  • I then tried the method I explained above with changing the commands for the Tab key, and if I press Tab instead of Enter, I've been finding that sometimes the grid view will retain focus and run my custom command and other times it'll move focus to the next control in the window and never run my custom command as a result.
  • In the cases when the above does retain focus on the grid view, while I think I solved the issues with CurrentCellInfo, scrolling the grid view to the new row has been hit or miss. Sometimes it works and the success callback is called, sometimes it doesn't work and the failure callback is called instead. I've also noticed that while the current cell has the proper selection border on it, I've also seen a different cell in the grid have the focus border on it.
  • The last thing I tried was removing all the commands entirely if the Tab key is pressed (but leave things as above for the Enter key, that is only the move next and my custom command) in that same situation, but because of that, I've found that the grid view loses focus.

If need be, I can provide a minimal example of what I've currently got that isn't working.

CyberBotX
Top achievements
Rank 2
Veteran
 answered on 18 May 2020
1 answer
124 views

Instead of placing the row details below the current row, would it be possible to dock the details to a certain area of the grid, e.g. top or bottom?

Thanks
Michael

 

Dinko | Tech Support Engineer
Telerik team
 answered on 18 May 2020
1 answer
178 views

Hello,

We are using the RadSyntaxEditor (R1 2020). Everything has been good with it but I wanted to report a possible bug. It isn't affecting our users because they are old and all have bad eyes, but someone somewhere might care :)

We have found that we can scroll to make the text larger but that anytime we scroll to 50% or lower the following exception gets thrown:

 

   Exception    {"'∞' is not a valid value for property 'Y2'."}    System.Exception {System.ArgumentException}

   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.Windows.Controls.SyntaxEditor.UI.Margins.LineNumberMargin.UpdateUIOverride(UIUpdateContext updateContext)
   at Telerik.Windows.Controls.SyntaxEditor.UI.Margins.SyntaxEditorMarginsCollection.UpdateUI(UIUpdateContext updateContext)
   at Telerik.Windows.Controls.SyntaxEditor.UI.Margins.SyntaxEditorMargins.UpdateUI(UIUpdateContext updateContext)
   at Telerik.Windows.Controls.SyntaxEditor.Layout.SyntaxEditorLayout.Arrange()
   at Telerik.Windows.Controls.SyntaxEditor.UI.SyntaxEditorPresenter.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at Telerik.Windows.Controls.LayoutControl.VerticalLayoutControlPanelStrategy.Arrange(Size finalSize)
   at Telerik.Windows.Controls.LayoutControl.LayoutControlPanel.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.Controls.ItemsPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.ScrollContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(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)

 

The syntax editor sits in a LayoutControlGroup inside a vertically oriented RadLayoutControl. The abbreviated xaml code looks something like this below:

<telerik:LayoutControlGroup x:Name="TopLayout"
                                        Orientation="Vertical"
                                        Height="400"
                                        FocusManager.FocusedElement="{Binding ElementName=SyntaxEditor}">
                <telerik:RadToolBar ... />
                <telerik:RadSyntaxEditor Name="SyntaxEditor"
                                         IsTabStop="True"
                                         AcceptsReturn="True"
                                         Focusable="True"
                                         Language="Sql"
                                         CaretDisplayMode="Normal"
                                         KeyDown="SyntaxEditor_KeyDown"
                                         ScrollViewer.VerticalScrollBarVisibility="Visible"
                                         PreviewSyntaxEditorMouseLeftButtonDown="SyntaxEditor_PreviewSyntaxEditorMouseLeftButtonDown"
                                         SelectionChanged="SyntaxEditor_SelectionChanged"
                                         DocumentContentChanging="SyntaxEditor_DocumentContentChanging"/>
            </telerik:LayoutControlGroup>

 

Hope this helps.

Tim

Petar Mladenov
Telerik team
 answered on 18 May 2020
11 answers
651 views

The GridView has a nasty feature I don't quite understand. It concerns the visual studio intellisense connection (XAML) of the collection in the ItemsSource and the DataMemberBinding on the column when using AutoGenerateColumns=False.

The problem is that if you Qualify the attached property type, so it reacts to property name changes and can be naviagted to using F12, the column cannot be filtered or grouped anymore.

Qualify looks like this:

DataMemberBinding="{Binding Path=(model: xxx)"

The unqualified looks like this:

DataMemberBinding="{Binding Path= xxx"       this gives a blue line underneath

 

The DataContext of the column obviously isn't the DataContext of the Window.

The values in the cells are correct. 

The message I get from visual studio is  'Cannot resolve property 'xxx' in data context of type 'object'.

In DataTemplates a similar thing happens, but you can set the DataType or I use d:DataContext={xxx}

 

I there a way to do this?

 

 

 

Yoan
Telerik team
 answered on 15 May 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
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
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
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?