Telerik Forums
UI for WPF Forum
2 answers
254 views

Hello team,

I am persisting the grid settings. And I have a button in each gridview's control panel as "Reset to default".

I am deleting the related bin file, but the default settings (as stated in xaml) is not being reflected to current grid in screen. I tried, rebinding/re assigning itemssource/InvalidateVisual with no luck. How can i reset the gridview settings, without being have to keep a default bin file and restoring that bin file, when the user clicks "reset to default".

Martin Ivanov
Telerik team
 answered on 11 May 2018
3 answers
188 views
If I have the MinValue set to 0 and I enter a negative value in the control, the value is getting set back to 0. How would I change the behavior to change the value to the absolute value of the entry rather than zero? I already have a control built that extends from RadNumericUpDown, just not sure what to hook up to to update the value. Thanks!
Stefan
Telerik team
 answered on 11 May 2018
7 answers
245 views

Hello,

We're using the RadRichTextBox control with the Windows8 Theme.
And it's possible to insert an image in the text but as soon as the user tries to select this image to resize it, the application crashes:

An unhandled exception of type 'System.NullReferenceException' occurred in PresentationFramework.dll

At first I thought we were doing something wrong, so I've tried to recreate the problem in one the the sample projects.
By doing so I've noticed that this problem occurs only when using the Windows8 Theme. Changing the theme to Windows7 for example makes the issue disappear. But this is not an actual solution for us, because we'd like to be able to use the Windows8 theme too.

I've attached a screenshot of the exception details. I apologise for it being in Dutch but I believe it still to be of use here.
It says that the resource key RadButtonStyle is missing. I'd like to point out again that this seems to only occur with the Windows8 theme.

To recreate the problem you can use the SaveAndSaveAs_WPF sample project and just set the theme of the RadRichTextBox control to Windows8.
You can just take a screenshot and paste it in the RadRichTextBox, when you try to resize this image the NullReferenceException should be thrown.
Below is an example of the adjusted MainWindow.xaml:

<Window x:Class="SaveAndSaveAs_WPF.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Grid.Row="0" >
            <telerik:RadButton  Content="New" Click="NewDocumentButton_Click" Padding="25,5" Margin="5" />
            <telerik:RadButton  Content="Open" Click="OpenButton_Click" Padding="25,5" Margin="5" />
            <telerik:RadButton  Content="Save" Click="SaveButton_Click"  Margin="5" Padding="25,5"/>
            <telerik:RadButton  Content="Save As" Click="SaveAsButton_Click"  Margin="5" Padding="25,5"/>
        </StackPanel>
        <telerik:DocumentRuler Grid.Row="1">
            <telerik:RadRichTextBox
                    telerik:Analytics.Name="rtb"
                    x:Name="radRichTextBox"
                    IsSpellCheckingEnabled="False"
                    LayoutMode="Paged"
                    AllowDrop="True" >
                <telerik:RadRichTextBox.Style>
                    <Style TargetType="telerik:RadRichTextBox">
                        <Setter Property="telerik:StyleManager.Theme" Value="Windows8" />
                    </Style>
                </telerik:RadRichTextBox.Style>
            </telerik:RadRichTextBox>
        </telerik:DocumentRuler>
    </Grid>
</Window>

 

Is there anything we could to in order to bypass this problem and still use the Windows8 theme?

 

Tanya
Telerik team
 answered on 11 May 2018
9 answers
1.0K+ views
I would like to use a glyph for the image or a RadRibbonBackstageItem, but since it expects an Icon, it doesn't seem possible. Is there some way to do it?
Kalin
Telerik team
 answered on 09 May 2018
2 answers
227 views
We’re using a couple of other Telerik controls that incorporate selection, but few if any swap to using a hand cursor for selection. We’d like to enabled selection in the Tree Map but override the default cursor so that it uses the standard Arrow cursor. Is this possible without modifying the underlying source for the control?
Chris
Top achievements
Rank 1
 answered on 09 May 2018
1 answer
340 views

I have an expander that contains sub-expanders. I want to automatically close the sub-expanders when I close the main expander. I have implemented this logic using data binding, but it doesn't seem to work correctly.

Looks like binding to the IsExpanded property gets destroyed after you close the expander using the expander's button. Have omitted a call to the SetCurrentValue method...?

Example project attached. See the ReadMe.txt for details.

Pretty frustrating that you don't allow attaching archives. Doesn't encourage that much creating example projects. Your ticket system is a pain in the donkey if you are a consultant. Things could be done more easily and efficiently.

Anyways, here's a Google Drive link to download the project: https://drive.google.com/drive/folders/1JvBukVvfmxWsRW5Wb-nRXbT5a6EOWvCd

Let me know when you have downloaded it so I can delete the file.

Martin Ivanov
Telerik team
 answered on 09 May 2018
5 answers
643 views

I want to sort my items via a custom sort order, similar to the implementation detailed here: http://docs.telerik.com/devtools/wpf/controls/radgridview/sorting/custom#custom-sorting-handling-sorting-event

However when I do it seems that e.OldSortingState is always equal to SortingState.None and so I don't get the functionality where first click on column = Ascending, second = Descending, and third = reset to default sorting (ie. None).

The example below should mostly set the sorting to the way it would be if I didn't handle the Sorting event myself. It's only for demonstration. My issue is that I can't ever get to the "else if" and "else" blocks.

private void MainDataGridOnSorting(object sender, GridViewSortingEventArgs e)
 {
     RadGridView radGridView = e.Source as RadGridView;
 
     if (radGridView == null)
     {
         e.Cancel = true;
         return;
     }
 
     DataView dataView = radGridView.DataContext as DataView;
 
     if (dataView == null)
     {
         e.Cancel = true;
         return;
     }
 
     IEnumerable<DataRowView> dataRows = dataView.Cast<DataRowView>();
 
     //If the sorting state is none, sort the items ascending.
     if (e.OldSortingState == SortingState.None)
     {
         e.NewSortingState = SortingState.Ascending;
         e.Column.SortingState = SortingState.Ascending;
 
         dataRows =
             dataRows
                 .OrderBy(row => row.Field<string>(e.Column.UniqueName));
     }
     //If the sorting state is none, sort the items descending.
     else if (e.OldSortingState == SortingState.Ascending)
     {
        // Cannot reach this block
         e.NewSortingState = SortingState.Descending;
         e.Column.SortingState = SortingState.Descending;
 
         dataRows =
             dataRows.OrderByDescending(row => row.Field<string>(e.Column.UniqueName));
     }
     //If the sorting state is descending, apply default sorting to the items.
     else
     {
        // Cannot reach this block
         e.NewSortingState = SortingState.None;
         e.Column.SortingState = SortingState.None;
 
         dataRows =
             dataRows.OrderBy(row => row.Field<int>("PrimaryRow"));
     }
 
     radGridView.ItemsSource = dataRows;
     e.Handled = true;
     e.Cancel = true;
 }
Dilyan Traykov
Telerik team
 answered on 09 May 2018
1 answer
227 views
Example : RadComboBox conatains below list
Computer
Computer Engineer
Free
Free trial

When I type "Comp" in text area of RadCombox it should auto complete with default selection that is "Computer" in text area
and show drop down with "Computer" and "Computer Engineer"
Dilyan Traykov
Telerik team
 answered on 09 May 2018
12 answers
2.8K+ views
What is the WPF equivalent of the TextChanged event?  I have a RadComboBox that allows editing and when the text changes I need to raise perform some work.

Thanks in advance,
Lee
Martin Ivanov
Telerik team
 answered on 09 May 2018
3 answers
153 views

Hello,

I'm using a RadDiagram where the users can add images and draw arrows.

By default, when the user draws an arrow over a shape, the arrow connects to the closest connection point. I need to modify this behavior. When the ActiveTool is ConnectorTool and the user clicks on the image, the arrow must start from the point where the user clicked, and not from the closest connection point.

 

In order to achieve this, I removed all connection points from the image when I add it. This didn't work as expected.

The following code sample allows me te reproduce the error. When I click outside the image, the behavior is nominal.

When I click on the image, an exception is thrown. Instead, I want the application to behave as if the image wasn't there.

In my sample, the ActiveTool is always ConnectorTool, but in my real application, the ActiveTool can have other values. This behavior must only apply to the ConnectorTool. For example, when the PointerTool is active, the user must be able to select and move the image.

 

 

 

 

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        TestWindow win = new TestWindow();
        win.ShowDialog();
    }
}
 
 
class TestWindow : Window
{
    public TestWindow()
    {
        Grid main_grid = new Grid();
        main_grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
        main_grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
 
        RadDiagram my_diagram = new RadDiagram();
        my_diagram.ActiveTool = Telerik.Windows.Diagrams.Core.MouseTool.ConnectorTool;
        Grid.SetColumn(my_diagram, 1);
 
        ViewModel vm = new ViewModel(my_diagram);
 
        Button button_add_image = new Button();
        button_add_image.Content = "Add image";
        button_add_image.Command = vm.CommandAddImage;
 
        AddChild(main_grid);
        main_grid.Children.Add(my_diagram);
        main_grid.Children.Add(button_add_image);
 
        DataContext = vm;
    }
}
 
class ViewModel : ViewModelBase
{
    public ViewModel(RadDiagram diagram)
    {
        MyDiagram = diagram;
    }
 
    public RadDiagram MyDiagram { get; set; }
    public ICommand CommandAddImage { get { return new ICommandImpl(AddImage); } }
 
    public void AddImage()
    {
        Microsoft.Win32.OpenFileDialog open_file_dialog = new Microsoft.Win32.OpenFileDialog();
        open_file_dialog.Filter = "Image Files (*.png, *.jpg, *.bmp)|*.png;*.jpg;*.bmp";
        open_file_dialog.CheckFileExists = true;
 
        if (!open_file_dialog.ShowDialog().GetValueOrDefault() || !System.IO.File.Exists(open_file_dialog.FileName))
        { return; }
 
        System.Windows.Media.Imaging.BitmapImage image_source = new System.Windows.Media.Imaging.BitmapImage(new Uri(open_file_dialog.FileName));
        System.Windows.Controls.Image image_displayed = new System.Windows.Controls.Image();
        image_displayed.Source = image_source;
        Viewbox viewbox_added_to_diagram = new Viewbox();
        viewbox_added_to_diagram.Stretch = Stretch.Fill;
        viewbox_added_to_diagram.Margin = new System.Windows.Thickness(-4);
        viewbox_added_to_diagram.Child = image_displayed;
 
        RadDiagramShape shape_added_to_diagram = new RadDiagramShape();
        shape_added_to_diagram.Content = viewbox_added_to_diagram;
        shape_added_to_diagram.Background = Brushes.Transparent;
        shape_added_to_diagram.BorderBrush = Brushes.Green;
 
        shape_added_to_diagram.Connectors.Clear();
        MyDiagram.AddShape(shape_added_to_diagram, new Point(20, 20));
    }
 
 
    private class ICommandImpl : ICommand
    {
        private Action Command;
        public ICommandImpl(Action p_action) { Command = p_action; }
        public void Execute(object parameter) { Command(); }
        public bool CanExecute(object parameter) { return true; }
        public event EventHandler CanExecuteChanged;
    }
}

 

 

I followed the instructions in another post, but I didn't manage to make it work.

I used added the following tool, but the behavior is not what I need. Now, when I click on a shape, nothing happens. I want a new connection to start when I click on a shape.

class CustomConnectionTool : ConnectionTool
{
    public override bool MouseDown(PointerArgs e)
    {
        if (!this.IsActive) return false;
 
        var hitItem = this.HitTestService.ItemUnderMouse as IShape;
        if (hitItem == null || hitItem.Connectors.Count > 0)
            return base.MouseDown(e);
        else
            return false;
    }
}

 

The post suggested creating a new service or a custom tool, but I couldn't figure it out. In addition, my real application has more styles and custom behavior associated with Connections, so I'd rather not use a different class.

 

How else can I achieve what I need ? When the user clicks a shape, it must not start from the closest connection, but must instead start from the point where the user clicked.

Petar Mladenov
Telerik team
 answered on 08 May 2018
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
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
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
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?