Telerik Forums
UI for WPF Forum
2 answers
15 views

I am attempting to use the desktop alert but instead of reacting to a click on the content I want a button.  How do I route this?

View Model Method; show the alert (works)

        private void ShowAlert()
        {
            if (IsShowAlert &&
                AlertTitle.IsNotNullOrEmpty() &&
                AlertText.IsNotNullOrEmpty())
            {
                // Create a new BitmapImage
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri("pack://application:,,,/Images/GSI_Cloud_256.ico");
                bitmap.EndInit();

                var image = new System.Windows.Controls.Image() { Source = bitmap };

                desktopAlertManager.ShowAlert(new DesktopAlertParameters
                {
                    Header = AlertTitle,
                    Content = AlertText,
                    Icon = image,
                    IconColumnWidth = 48,
                    IconMargin = new Thickness(10, 0, 20, 0),
                    ShowDuration = AlertShowDuration,
                    Command = new DelegateCommand(OnAlertCommandExecuted)
                });
            }
        }

 
Respond to the Button Press:
        private void OnAlertCommandExecuted(object param)
        {
            IsShowTrayApp = true;
        }

Alert Style with a Button:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation">

    <SolidColorBrush x:Key="DesktopAlert_BorderBrush" Color="#FF848484"/>
    <LinearGradientBrush x:Key="DesktopAlert_Background" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="Cornsilk" Offset="0"/>
        <GradientStop Color="#FFD4D4D4" Offset="1"/>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="DesktopAlert_InnerBorderBrush" Color="#FFFFFFFF"/>
    <CornerRadius x:Key="DesktopAlert_CornerRadius">1</CornerRadius>
    <SolidColorBrush x:Key="DesktopAlert_ButtonIconStroke" Color="#FFFFFFFF"/>
    <LinearGradientBrush x:Key="DesktopAlert_ButtonIconFill" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FF282828"/>
        <GradientStop Color="#FF7C7C7C" Offset="1"/>
    </LinearGradientBrush>

    <DataTemplate x:Key="RadDesktopAlertHeaderTemplate">
        <Grid 
            x:Name="Header" 
            Grid.Column="1" 
            Grid.Row="0" 
            VerticalAlignment="Top" 
            HorizontalAlignment="Stretch"
            Background="{StaticResource ContainerHeaderBackgroundBrush}">

            <StackPanel
                HorizontalAlignment="Left"
                Orientation="Horizontal">

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="30" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <Image 
                        RenderOptions.BitmapScalingMode="Fant"
                        Margin="5 0 5 0"
                        Source="/Images/GSI_Cloud_256.ico"/>

                    <Label
                        Grid.Column="1"
                        Foreground="White"
                        FontWeight="SemiBold"
                        FontSize="14"
                        VerticalContentAlignment="Center"
                        VerticalAlignment="Center"/>
                </Grid>
                
            </StackPanel>

            <StackPanel
                HorizontalAlignment="Right"
                Orientation="Horizontal">

                <Button Height="30" Width="30"  
	                x:Name="DesktopAlert_CloseButton" 
                    Content="🗙"
                    Background="Transparent"
                    BorderThickness="0"
                    Foreground="White"
                    FontSize="20"
                    Margin="0 -3 0 0"
                    FontWeight="Bold"
                    Command="{x:Static telerikNavigation:DesktopAlertCommands.Close}" />

            </StackPanel>

            <ContentPresenter 
                Content="{Binding}" 
                TextBlock.FontWeight="Bold" 
                Margin="0 0 0 0" 
                MinHeight="{Binding ActualHeight, ElementName=DesktopAlert_CloseButton}" Grid.RowSpan="2" VerticalAlignment="Top">

                <ContentPresenter.Resources>
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="TextWrapping" Value="Wrap"/>
                        <Setter Property="Foreground" Value="White" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                        <Setter Property="HorizontalAlignment" Value="Left" />
                        <Setter Property="Margin" Value="30 0 0 0" />
                    </Style>
                </ContentPresenter.Resources>
            </ContentPresenter>

        </Grid>
    </DataTemplate>

    <ControlTemplate x:Key="RadDesktopAlertTemplate" TargetType="{x:Type telerikNavigation:RadDesktopAlert}">
        <Grid x:Name="LayoutRoot">
            <Border Background="White"
                    BorderThickness="{TemplateBinding BorderThickness}" 
                    CornerRadius="{StaticResource DesktopAlert_CornerRadius}">

                <Border BorderBrush="{StaticResource DesktopAlert_InnerBorderBrush}" BorderThickness="1">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="26" />
                        </Grid.RowDefinitions>
                        
                        <ContentPresenter 
                            ContentTemplate="{TemplateBinding HeaderTemplate}" 
                            Grid.Column="1" 
                            Content="{TemplateBinding Header}" 
                            Grid.Row="0" VerticalAlignment="Top"/>

                        <ContentPresenter 
                            x:Name="Content" 
                            Cursor="Hand" 
                            Grid.Column="1" 
                            HorizontalAlignment="Center" 
                            Margin="0 7 0 0" Grid.Row="1" VerticalAlignment="Top">

                            <ContentPresenter.Resources>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="TextWrapping" Value="Wrap"/>
                                    <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
                                    <Setter Property="HorizontalAlignment" Value="Center" />
                                    <Setter Property="FontSize" Value="14" />
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>

                        <Grid Grid.Row="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="126" />
                            </Grid.ColumnDefinitions>

                            <Button
                                Style="{StaticResource ButtonStyle}"
                                Grid.Column="2"
                                Content="Open" 
                                Command="{Binding OnAlertCommandExecuted}"/>
                        </Grid>
                    </Grid>
                </Border>
            </Border>
        </Grid>
    </ControlTemplate>

    <Style TargetType="{x:Type telerikNavigation:RadDesktopAlert}">
        <Setter Property="Padding" Value="10 8"/>
        <Setter Property="Opacity" Value="0.9"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="FontFamily" Value="Segoe UI"/>
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="{StaticResource DesktopAlert_BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Width" Value="360"/>
        <Setter Property="Height" Value="130"/>
        <Setter Property="Template" Value="{StaticResource RadDesktopAlertTemplate}"/>
        <Setter Property="HeaderTemplate" Value="{StaticResource RadDesktopAlertHeaderTemplate}"/>
    </Style>
</ResourceDictionary>


 

 

 

Stenly
Telerik team
 answered on 24 May 2024
0 answers
16 views

RadRichTextBox is not allowing copy pasting from different document and also from another RadRichTextBox. 
If I am copying from same RadRichTextBox and then pasting it to same RadRichTextBox, then it is working fine.

So, I took reference from below doc:

WPF RichTextBox - Clipboard Support - Telerik UI for WPF

and implemented below function:

private void RadRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e) 
{ 
    if (e.Command is PasteCommand) 
    { 
        e.Cancel = true; 
        // Obtain the document inside the clipboard 
        RadDocument document = ClipboardEx.GetDocument().ToDocument(); 
 
        // Change it according to your needs 
        document.Selection.SelectAll(); 
        RadDocumentEditor editor = new RadDocumentEditor(document); 
        editor.ChangeFontSize(Unit.PointToDip(12)); 
 
        // Insert it in RadRichTextBox 
        this.radRichTextBox.InsertFragment(new DocumentFragment(document)); 
    } 
} 


I observed that if I am copying from another doc and pasting to that RadRichTextBox then 

RadDocument document = ClipboardEx.GetDocument().ToDocument(); 

this line is giving System.NullReferenceException: 'Object reference not set to an instance of an object.'

How to fix this?

Shraddha
Top achievements
Rank 1
 asked on 24 May 2024
0 answers
11 views
Is the TableShape solution from the Demos application available for download? I've tried using the SDK samples browser and looking in Github repo. I can't find it. Also, does it support Drag and Drop?
Will
Top achievements
Rank 1
Iron
 asked on 23 May 2024
1 answer
27 views
Hi! I'm trying to add new row in NOT edit mode, but new row always in edit mode. Is it possible to add new row in NOT edit mode?

Example: 


public class CustomKeyboardCommandProvider : DefaultKeyboardCommandProvider
	{
		private GridViewDataControl parentGrid;

		public CustomKeyboardCommandProvider(GridViewDataControl grid)
		 : base(grid)
		{
			this.parentGrid = grid;
		}

		public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
		{
			List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();

			if (key == Key.Enter)
			{
				commandsToExecute.Clear();
				commandsToExecute.Add(RadGridViewCommands.CommitEdit);
				commandsToExecute.Add(RadGridViewCommands.BeginInsert);
				commandsToExecute.Add(RadGridViewCommands.CommitEdit);
				
				this.parentGrid.ChildrenOfType<GridViewScrollViewer>().First().ScrollToEnd();
			}

			return commandsToExecute;
		}
	}

Stenly
Telerik team
 answered on 23 May 2024
1 answer
12 views

Hello,

I am currently working with RadDocking and trying to achieve the following scenario: I have three RadSplitContainers named left, middle, and right. My goal is to make the middle RadSplitContainer auto resizable when either the left or right Rad containers are set to auto hide. In other words, I want the middle container to automatically adjust its size to accommodate the space left by the hidden containers. Could you please guide me on how to achieve this behavior?

Thank you

Here is my code:

 <telerik:RadDocking  BorderThickness="0" Name="RadDocking" >
     <telerik:RadSplitContainer Orientation="Vertical" InitialPosition="DockedLeft"  Width="270" Height="840">
         <telerik:RadPaneGroup Name="TopLeft"  TabStripPlacement="Top" VerticalAlignment="Top"  Height="200 " >
             <telerik:RadPane Name="TopLeft1" Header="TopLeft1" >
             </telerik:RadPane>
             <telerik:RadPane Name="TopLeft2" Header="TopLeft2" />
         </telerik:RadPaneGroup>
         <telerik:RadPaneGroup Name="BottomLeft" TabStripPlacement="Top" >
             <telerik:RadPane Name="BottomLeft1" Header="BottomLeft2">
             </telerik:RadPane>
             <telerik:RadPane Name="BottomLeft2" Header="BottomLeft2" >
             </telerik:RadPane>
         </telerik:RadPaneGroup>
     </telerik:RadSplitContainer>
     <telerik:RadSplitContainer   Width="600" >
         <telerik:RadPaneGroup Background="GhostWhite"  >
             <telerik:RadPane  Name="Middle1" Header="Middle" Tag="Blue" CanUserClose="True" Background="Transparent" >
             </telerik:RadPane>
         </telerik:RadPaneGroup>
     </telerik:RadSplitContainer>
     <telerik:RadSplitContainer  InitialPosition="DockedRight" Name="TopRight" Width="350" Height="640">
         <telerik:RadPaneGroup >
             <telerik:RadPane Header="TopRight" >
             </telerik:RadPane>
         </telerik:RadPaneGroup>
     </telerik:RadSplitContainer>
 </telerik:RadDocking>

Thank you!

 

Martin Ivanov
Telerik team
 answered on 22 May 2024
1 answer
10 views

Is there a way to drag from a radtreeview control and get the drop event in a C++ Windows window.  We do get the event, but we do not know how to get access to the data.   Can we override the drag and drop and do our own implementation?

Mike

 

Martin Ivanov
Telerik team
 answered on 22 May 2024
1 answer
14 views
I have a complex merged table in RadRichTextBox. I want to know when I copy that table, what is copied to clipboard? I can paste it into microsoft word no issues manually. 

I am just wanting to know is it XML that is copied? What is on the clipboard when you used right click copy?
Dimitar
Telerik team
 answered on 22 May 2024
1 answer
21 views

RadGridView when source is RadDataPager + IQueryable/QueryableCollectionView:

RadGridView when source is RadDataPager + QueryableDataServiceCollectionView:

Why is the filter list empty when using IQueryable/QueryableCollectionView and how to fix this? Sample attached.

Stenly
Telerik team
 answered on 21 May 2024
1 answer
13 views

WPF Chart - Empty Values - Telerik UI for WPF

I have added link for EmptyPointBehaviour for wpf but it's available for windows, I want to implement same for wpf or uwp xaml UI. 

Martin Ivanov
Telerik team
 answered on 21 May 2024
1 answer
13 views

Hi,

I use this behavior to manage multiple selection on radgridview (with selection mode = "extended" and with GridViewSelectColumn)

It works but when I try to initialize the selection with some items at the end of initialization I receive the OnSelectionChanged that remove all the elements selected but the first.

public class GridViewMultiSelect : Behavior<RadGridView>
{
	protected override void OnAttached()
	{
		base.OnAttached();
		AssociatedObject.DataContextChanged += OnDataContextChanged;
		AssociatedObject.SelectedItems.CollectionChanged += OnSelectedItemsChanged;
		AssociatedObject.SelectionChanging += OnSelectionChanged;
		AssociatedObject.Items.CollectionChanged += OnItemsChanged;
	}

	private void OnSelectionChanged(object? sender, SelectionChangingEventArgs e)
	{
		
	}

	private void OnItemsChanged(object? sender, NotifyCollectionChangedEventArgs e)
	{
	}

	private void Select(IEnumerable<NsMisuraViewWithType> misure)
	{
		foreach (var item in misure)
		{
			AssociatedObject.SelectedItems.Add(item);
		}
	}

	private void OnDataContextChanged(object? sender, DependencyPropertyChangedEventArgs e)
	{
		if (AssociatedObject.DataContext is LoadedMeasurmentsVM viewModel)
		{
			viewModel.SelectAction = Select;
			SetSelectMeasurements();
		}
	}

	private void SetSelectMeasurements()
	{
		if (AssociatedObject.DataContext is LoadedMeasurmentsVM viewModel)
		{
			foreach (var item in AssociatedObject.SelectedItems)
			{
				if (viewModel.SelectedMeasurements.All(m => m.Misura.Id != ((NsMisuraViewWithType)item).Misura.Id))
				{
					viewModel.SelectedMeasurements.Add((NsMisuraViewWithType)item);
				}
			}
		}
	}

	private void OnSelectedItemsChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
	{
		SetSelectMeasurements();
	}

	protected override void OnDetaching()
	{
		base.OnDetaching();
		AssociatedObject.DataContextChanged -= OnDataContextChanged;
		AssociatedObject.SelectedItems.CollectionChanged -= OnSelectedItemsChanged;
	}
}
Dimitar
Telerik team
 answered on 21 May 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?