Telerik Forums
UI for WPF Forum
3 answers
239 views
            <telerikNavigation:RadPanelBar Orientation="Horizontal" Height="100"  HorizontalAlignment="Stretch">
                <telerikNavigation:RadPanelBarItem Header="Photo" >
                </telerikNavigation:RadPanelBarItem>
                <telerikNavigation:RadPanelBarItem Header="Page">
                    <ctrl:ctrl />
                </telerikNavigation:RadPanelBarItem>
                <telerikNavigation:RadPanelBarItem Header="Cover>
                    <ctrl:ctrl />
                </telerikNavigation:RadPanelBarItem>
            </telerikNavigation:RadPanelBar>

From the code above, if the content inside the "Page" RadPanelBarItem is too long, the scrollbar will appear.
But this scrollbar appear in RadPanelBar but not that particular PanelBarItem itself.
And if you can want to click "Cover" RadPanelBarITem, you got to scroll to the end of the RadPanelBar to see it.

So, is there anyway to make the scrollbar appear inside the RadPanelBarItem itself but not in RadPanelBar.
Besides, the scrollbar located at top, it block the appearance of Header in RadPanelBarItem.
Can make it locate at bottom instead? More make sense.
Vladimir Stoyanov
Telerik team
 answered on 15 Jun 2020
4 answers
685 views

Hello Telerik,

in the WPF RadRichTextBox I have this example text:

"Hello my friend, everything is great today".

Now the user selects only the word 'great' and I want to increase the fontsize +2 only for this word.

My code looks like this:

private async Task<bool> FormatIncreaseFont()
        {
            await Task.Delay(1);

            double newFontSize = 0;

            var boxes = RichTextBox.Document.Selection.GetSelectedBoxes();

            foreach (var box in boxes)
            {

                //AssociatedDocumentElement is wrong.
                Span span = box.AssociatedDocumentElement as Span;
                if (span != null)
                {
                    newFontSize = (newFontSize == 0) ? Math.Round(Unit.DipToPoint(span.FontSize), 0) + 2 : newFontSize;

                    //span.FontSize is also wrong
                    span.FontSize = Unit.PointToDip(newFontSize);
                }
            }

            RichTextBox.UpdateEditorLayout();

            return true;
        }

AssociatedDocumentElement is the span where the InlineLayoutBox lives in, so I get the wrong font size.

Also I am changing the font size of the whole span, not only the InlineLayoutBox .

 

My questions are:

1.) How do I get the current font size of the InlineLayoutBox ("great").

2.) How do I then change the font size only for this InlineLayoutBox ("great").

 

Thank you!

Dimitar
Telerik team
 answered on 15 Jun 2020
4 answers
227 views
The legend text is getting cut off.  There does not seem to be any pattern to the issue.  I am using Microsoft Visual Studio Community 2019 and have Telerik installed.  I have created several graphs and have gone into the graph properties of the graph.  I selected Series --- <Then the bar Series> --- LegendItem and entered the value.  The text is getting cut off.  I have attached several screen shots. 

Martin Ivanov
Telerik team
 answered on 15 Jun 2020
2 answers
330 views
I can move around using the ar row keys just fine, but after editing a cell I press enter to commit. If I then try to move around it will go straight into edit-mode instead of moving around - how can I change this behaviour?
Vladimir Stoyanov
Telerik team
 answered on 15 Jun 2020
2 answers
888 views
Hi,

I currently trying to convert a Winforms Project to WPF Project. As step one I need to create a Tabbed MDI container in WPF in which each new RadItemTab will contain a WindowsFormHost which will again contain the existing WinForm UserControl.

We got the RadControl to work up to our expectation but unable to include the WindowsFormHost.

I'm pasting the sample of what i was trying out would really appreciate your help on this.

Download
Full Project

Or

AnotherTab.xaml
<UserControl x:Class="FcWpfTabControl.AnotherTab"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:xx="clr-namespace:FcWpfTabControl"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style x:Key="CloseButton" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Trigger.EnterActions>
                                    <BeginStoryboard x:Name="MouseOverBeginStoryboard">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames
                                                    Storyboard.TargetProperty="(UIElement.Visibility)"
                                                    Storyboard.TargetName="FocusEllipse">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ColorAnimation Duration="0" To="LightGray"
                                                    Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                                    Storyboard.TargetName="FocusEllipse" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <StopStoryboard BeginStoryboardName="MouseOverBeginStoryboard" />
                                </Trigger.ExitActions>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Trigger.EnterActions>
                                    <BeginStoryboard x:Name="IsPressedBeginStoryboard">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames
                                                    Storyboard.TargetProperty="(UIElement.Visibility)"
                                                    Storyboard.TargetName="FocusEllipse">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ColorAnimation Duration="0" To="DarkGray"
                                                    Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                                    Storyboard.TargetName="FocusEllipse" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <StopStoryboard BeginStoryboardName="IsPressedBeginStoryboard" />
                                </Trigger.ExitActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                        <Grid Background="Transparent" Width="14" Height="14">
                            <Ellipse x:Name="FocusEllipse" Fill="#FFF13535" Visibility="Collapsed" />
                            <ContentPresenter x:Name="ContentPresenter"
                                    Content="{TemplateBinding Content}" HorizontalAlignment="Center"
                                    VerticalAlignment="Center" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ClosableStyle" TargetType="telerik:RadTabItem">
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding Title}" />
                                <telerik:RadButton Grid.Column="1" Style="{StaticResource CloseButton}"
                                                Width="16" Height="16"
                                    Margin="10,0,0,0" ToolTipService.ToolTip="Remove item"
                                              xx:RoutedEventHelper.EnableRoutedClick="True"
                                              Padding="0" >
                                <ContentControl>
                                        <Path Data="M0,0 L6,6 M6, 0 L0,6" Stroke="Black" StrokeThickness="1"
                                SnapsToDevicePixels="True" />
                                </ContentControl>
                            </telerik:RadButton>
                  
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <!--<ContentControl Content="{Binding Content}"/>-->
                    <DockPanel Name="panel1" LastChildFill="True">
                        <WindowsFormsHost Name="wfHost" DockPanel.Dock="Left" Child="{Binding Content}"/>
                    </DockPanel>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadTabControl x:Name="tabControl" ItemContainerStyle="{StaticResource ClosableStyle}">
        </telerik:RadTabControl>
    </Grid>
</UserControl>

AnotherTab.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using System.Collections.ObjectModel;
using System.Windows.Forms.Integration;
using System.Windows.Forms;
 
namespace FcWpfTabControl
{
    /// <summary>
    /// Interaction logic for AnotherTab.xaml
    /// </summary>
    public partial class AnotherTab : System.Windows.Controls.UserControl
    {
        public AnotherTab()
        {
            InitializeComponent();
             
            EventManager.RegisterClassHandler(typeof(RadTabItem), RoutedEventHelper.CloseTabEvent, new RoutedEventHandler(OnCloseClicked));
 
        }
        ObservableCollection<TabItemModel> tabItemsModel = new ObservableCollection<TabItemModel>();
 
        public void OnCloseClicked(object sender, RoutedEventArgs e)
        {
            var tabItem = sender as RadTabItem;
            // Remove the item from the collection the control is bound to
            tabItemsModel.Remove(tabItem.DataContext as TabItemModel);
        }
        public void CreateTabItem(UserControl uc)
        {
            // Create items:
 
            RadTabItem Item1 = new RadTabItem();
            WindowsFormsHost wfh = new WindowsFormsHost();
            wfh.Child = uc;
            Item1.Content = wfh;
            Item1.Header = "Tab1";
 
            TabItemModel tb = new TabItemModel("Item", uc);
           // tb.userControl = uc;
            tabItemsModel.Add(tb);
           // tabItemsModel[0].Content.Child = uc;
 
            tabControl.ItemsSource = tabItemsModel;
 
 
        }
    }
 
    public class TabItemModel
    {
        
        public TabItemModel(string stringTitle, UserControl uc)
        {
            WindowsFormsHost wfh = new WindowsFormsHost();
           //wfh.Child = uc;
            Title = stringTitle;
            Content = wfh;
             
        }
        public String Title
        {
            get;
            set;
        }
 
        public UserControl userControl
        {
            get;
            set;
        }
 
        public WindowsFormsHost Content
        {
            get;
            set;
        }
    }
}

RoutedEventHelper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Windows.Controls;
using System.Windows;
using System.Windows.Controls;
using Telerik.Windows;
 
 
namespace FcWpfTabControl
{
    public class RoutedEventHelper
    {
        //Create the routed event:
        public static readonly RoutedEvent CloseTabEvent = EventManager.RegisterRoutedEvent(
            "CloseTab",
            RoutingStrategy.Bubble,
            typeof(RoutedEventHandler),
            typeof(RoutedEventHelper));
        //Add an attached property:
        public static bool GetEnableRoutedClick(DependencyObject obj)
        {
            return (bool)obj.GetValue(EnableRoutedClickProperty);
        }
        public static void SetEnableRoutedClick(DependencyObject obj, bool value)
        {
            obj.SetValue(EnableRoutedClickProperty, value);
        }
        // Using a DependencyProperty as the backing store for EnableRoutedClick.
        // This enables animation, styling, binding, etc...
        public static readonly DependencyProperty EnableRoutedClickProperty = DependencyProperty.RegisterAttached(
            "EnableRoutedClick",
            typeof(bool),
            typeof(RoutedEventHelper),
            new System.Windows.PropertyMetadata(OnEnableRoutedClickChanged));
        private static void OnEnableRoutedClickChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var newValue = (bool)e.NewValue;
            var button = sender as Button;
            if (button == null)
                return;
            if (newValue)
                button.Click += new RoutedEventHandler(OnButtonClick);
        }
        static void OnButtonClick(object sender, RoutedEventArgs e)
        {
            var control = sender as Control;
            if (control != null)
            {
                control.RaiseEvent(new RadRoutedEventArgs(RoutedEventHelper.CloseTabEvent, control));
            }
        }
    }
}
dongchul
Top achievements
Rank 1
 answered on 15 Jun 2020
1 answer
140 views

Hello,

I have a requirement to display two x-axis for a single series. The data is a collection of measurements and the client would like to see each point relative to the start and also relative to the end. For example, if there are 10 points along a 100m distance, the third point is 30m from the start, and 70m from the end. Is there a way to accommodate this?

 

So far I have only found a way to make multiple x-axis for a chart, but each series in that chart only has one x-axis. My only thought was to create a second series with reverse data that would be included, but hidden under the first data since they line up perfectly. Is there another way? Thanks.

Martin Ivanov
Telerik team
 answered on 12 Jun 2020
0 answers
128 views

Hallo, I'm using RadWebCam control into a UserControl and everything works as expected.

So, if I call myradwebcam.TakeSnapShot() within the UserControl that contains the RadWebCam control, everything is ok.

But if I call myradwebcam.TakeSnapShot() from another class (i.e. another UserControl) I receive a System.NullReferenceException.

Am I doing something wrong?

 

Thank's,

Luca

P.S. Here the exception:

 

System.NullReferenceException
  HResult=0x80004003
  Messaggio=Riferimento a un oggetto non impostato su un'istanza di oggetto.
  Origine=Telerik.Windows.Controls.Media
  Analisi dello stack:
   in Telerik.Windows.Controls.RadWebCam.TakeSnapshot()
   in TestVisoreIfm.Pannello_Dashboard.btnScansione_Click(Object sender, RoutedEventArgs e) in D:\repos\TestVisoreIfm\Pannello_Dashboard.xaml.cs: riga 517

Luca
Top achievements
Rank 1
 asked on 11 Jun 2020
11 answers
200 views

Hello,

I have a window that contains a RadRibbonView:

<telerik:RadRibbonView x:Name="PART_MainMenu" BackstageClippingElement="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=telerik:RadDockPanel}}"  IsMinimizable="true">
            <telerik:RadRibbonView.Backstage>
                <telerik:RadRibbonBackstage x:Name="backstage" BackstagePosition="Office2013" Background="{StaticResource ATS_Brush_Gray240}">                                    <telerik:RadRibbonBackstageItem Header="Informations">
                        <Grid>
                            <TextBlock Text="Log-out" Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="DarkSlateGray"/>
                        </Grid>
                    </telerik:RadRibbonBackstageItem>                                       
                </telerik:RadRibbonBackstage>
            </telerik:RadRibbonView.Backstage>

</telerik:RadRibbonView>

 

I display a simple text "Log-out" in a single telerik:RadRibbonBackstageItem.

I change by code the property Thread.CurrentThread.CurrentUICulture to an arabic culture.

I change equally by code the property FlowDirection of the window to the value RightToLeft.

Because of property value inheritance, this property is supposed to be automatically changed for all child elements.

However, the text is mirrored (see file in attachment).

How can we fix that issue ?

 

Thanks,

Alexandre

Vladimir Stoyanov
Telerik team
 answered on 11 Jun 2020
1 answer
363 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
695 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
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?