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!
<
UserControl
x:Class
=
"FcWpfTabControl.AnotherTab"
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
>
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
;
}
}
}
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));
}
}
}
}
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.
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
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
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)
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.