Telerik Forums
UI for WPF Forum
2 answers
296 views

I have an application with a UserControl that contains a ListBox. The DataTemplate of the ListBox adds a button to each item. The ListBox is inside a BusyIndicator. If I set IsBusy to true from a command bound to a ListBox item the BusyIndicator does not show. If I set IsBusy from the constructor of the UserControl it does show. I am hoping you can tell me why it doesn't show from the command bound from the button.

Here is the xaml for the UserControl:

<UserControl
    x:Class="BusyIndicatorIssue.WidgetView"
    xmlns:local="clr-namespace:BusyIndicatorIssue"
    mc:Ignorable="d"
    d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.DataContext>
        <local:WidgetViewModel/>
    </UserControl.DataContext>
    <UserControl.Resources>
        <local:WidgetView x:Key="topLevelParent"/>
        <DataTemplate x:Key="WidgetListBoxDataTemplate">
            <DockPanel>
                <telerik:RadPathButton
                    DockPanel.Dock="Right"
                    PathGeometry="{telerik:RadGlyph Glyph=}"
                    Command="{Binding Source={StaticResource topLevelParent}, Path=DataContext.RunLongProcessCommand}"
                    CommandParameter="{Binding}"/>
                <TextBlock DockPanel.Dock="Left" FontSize="2" VerticalAlignment="Center" Text="{Binding Name}"/>
            </DockPanel>
        </DataTemplate>
    </UserControl.Resources>
    <telerik:RadBusyIndicator
        BusyContent="{Binding BusyContent}"
        IsBusy="{Binding IsBusy}"
        IsIndeterminate="True">
        <telerik:RadListBox
            x:Name="WidgetListBox" Padding="8"
            ItemsSource="{Binding Widgets, Mode=TwoWay}"
            ItemTemplate="{StaticResource WidgetListBoxDataTemplate}"/>
    </telerik:RadBusyIndicator>
</UserControl>

 

Here is the ViewModel code:

using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using Telerik.Windows.Controls;
 
namespace BusyIndicatorIssue
{
    public class WidgetViewModel : ViewModelBase
    {
        public WidgetViewModel()
        {
            Widgets = new ObservableCollection<Widget>
            {
                new Widget("Widget 1"),
                new Widget("Widget 2"),
                new Widget("Widget 3"),
                new Widget("Widget 4"),
                new Widget("Widget 5"),
                new Widget("Widget 6"),
                new Widget("Widget 7"),
                new Widget("Widget 8"),
                new Widget("Widget 9")
            };
            RunLongProcessCommand = new DelegateCommand(OnRunLongProcessCommandExecuted);
            //BusyContent = "Doing Something";
            //IsBusy = true;
        }
 
        public DelegateCommand RunLongProcessCommand { get; set; }
        public ObservableCollection<Widget> Widgets { get; set; }
 
        public const string IsBusyPropertyName = "IsBusy";
        private bool _isBusy;
        public bool IsBusy
        {
            get => _isBusy;
            set
            {
                if (_isBusy != value)
                {
                    _isBusy = value;
                    RaisePropertyChanged();
                }
            }
        }
 
        public const string BusyContentPropertyName = "BusyContent";
        private string _busyContent = default!;
        public string BusyContent
        {
            get => _busyContent;
            set
            {
                if (_busyContent != value)
                {
                    _busyContent = value;
                    RaisePropertyChanged();
                }
            }
        }
 
        private void OnRunLongProcessCommandExecuted(object parameter)
        {
            var widget = (Widget)parameter;
            IsBusy = true;
            BusyContent = $"Doing something with {widget}";
            var backgroundWorker = new BackgroundWorker();
            backgroundWorker.DoWork += DoWork;
            backgroundWorker.RunWorkerCompleted += RunWorkerCompleted;
            _ = MessageBox.Show($"About to do something with {widget.Name}.");
            backgroundWorker.RunWorkerAsync(widget);
        }
 
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            var widget = (Widget)e.Argument;
            System.Threading.Thread.Sleep(3000);
            _ = MessageBox.Show($"Done with {widget.Name}.");
        }
 
        private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var backgroundWorker = sender as BackgroundWorker;
            if (backgroundWorker is not null)
            {
                backgroundWorker.DoWork -= DoWork;
                backgroundWorker.RunWorkerCompleted -= RunWorkerCompleted;
                InvokeOnUIThread(() => { IsBusy = false; });
            }
        }
    }
}

 

Here is the MainWindow xaml that hosts the UserControl:

<Window x:Class="BusyIndicatorIssue.MainWindow"
        xmlns:local="clr-namespace:BusyIndicatorIssue"
        mc:Ignorable="d"
        Height="300" Width="400"
        Title="MainWindow">
    <DockPanel>
        <local:WidgetView
            DockPanel.Dock="Top"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"/>
    </DockPanel>
</Window>

 

This is the simple model I am using for testing:

namespace BusyIndicatorIssue
{
    public class Widget
    {
        public Widget(string name)
        {
            Name = name;
        }
        public string Name { get; set; }
    }
}

 

I was able to get the BusyIndicator to show by calling a command bound to a button placed directly in the main content of the UserControl. But I really need this application to have the buttons on each ListItem if possible.

 

Regards,

Don

Dilyan Traykov
Telerik team
 answered on 18 Nov 2020
1 answer
691 views

Hello,

I set up my telerik nuget server according to your documentation.
But, I can't find the Ui.for.Wpf.45 package.

I just find the .Wpf.netCore package.

Can you help me.

Thank you

best regards

Markus

 

Vesko
Telerik team
 answered on 17 Nov 2020
1 answer
255 views

Hi,

I just started valuating RADGrdiView.

grid is binded to a datatable.

-When editing a cell in a row and then moving to the next row, is there a way to not automatically going into edit mode ?

-When on the last row, is there a way to move to the new(which is at the button) without pressing (Insert) or clicking on the new row using the mouse? meaning is it possible to navigate to the new row using the keyboard arrows for example.

 

Thanks

Vladimir Stoyanov
Telerik team
 answered on 17 Nov 2020
2 answers
520 views
Hello there,

I want to be able to auto-resize a RadPane inside a RadDocking and RadSplitContainer up to the remaining place, when other sibling RadPanes get undocked and moved away per Drag&Drop.

Please, take a look at the attached code snippet for more info.

01.<telerik:RadDocking x:Name="dockEngineering" 
02.        Grid.Row="1"
03.        Margin="0,0,0,0"                                   
04.        BorderThickness="0"
05.        Padding="0"
06.        Background="{StaticResource LightGrayBrush}"
07.        x:FieldModifier="public">
08.    <telerik:RadDocking.DocumentHost>
09.        <telerik:RadSplitContainer x:Name="MiddleContainer">
10.            <telerik:RadPaneGroup x:Name="MiddleGroup">
11.                <telerik:RadPane x:Name="ProgressPane" Header="Progress View" >
12.                    <Grid Name="grdProgress">
13.                        <local:ProgressView DataContext="{Binding ProgressViewModel}"/>
14.                    </Grid>
15.                </telerik:RadPane>
16.            </telerik:RadPaneGroup>
17.        </telerik:RadSplitContainer>
18.    </telerik:RadDocking.DocumentHost>
19.</telerik:RadDocking>

There are other RadPanes parallel to ProgressPane, and 3 more RadSplitContainers parallel to RadDocking.DocumentHost inside RadDocking.
As said, when one of the other gets collapsed and more space is available at that docking position, I want the other RadPanes to stretch in size to take over that space.

How can I do this? Thanks.

Regards,
Baris
Hans
Top achievements
Rank 1
 answered on 17 Nov 2020
3 answers
452 views

I've got a RadGridView that contains a RowStyleSelector and an InputBindings section. The RowStyleSelector has 2 conditions, one checking if a value is true and one checking if a value is false. In the false case, the only thing being done is setting the style to be based on the existing GridViewRowStyle with no changes. In the true case, the same happens but the background color is changed. When the false case is used, my InputBindings work fine. Once the true case is used, though, my InputBindings stop working. (Related, I also use behaviors via Microsoft.Xaml.Behaviors.Wpf, with one of them being to bind a command to the MouseDoubleClick event, and that event also stops firing when the above happens with the InputBindings.)

I had set a breakpoint in my code to see if it the command was getting hit and it would only be hit when the false case happened above.

In the below example, assume that Items contains a Cond boolean property:

<telerik:RadGridView GroupRenderMode="Flat" IsReadOnly="True" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Items, Mode=OneWay}" RowIndicatorVisibility="Collapsed" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" ShowGroupPanel="False">
    <telerik:RadGridView.RowStyleSelector>
        <telerik:ConditionalStyleSelector>
            <telerik:StyleRule Condition="Cond">
                <Style BasedOn="{StaticResource GridViewRowStyle}" TargetType="{x:Type telerik:GridViewRow}">
                    <Setter Property="Background" Value="Orange"/>
                </Style>
            </telerik:StyleRule>
            <telerik:StyleRule Condition="!Cond">
                <Style BasedOn="{StaticResource GridViewRowStyle}" TargetType="{x:Type telerik:GridViewRow}"/>
            </telerik:StyleRule>
        </telerik:ConditionalStyleSelector>
    </telerik:RadGridView.RowStyleSelector>
    <telerik:RadGridView.InputBindings>
        <KeyBinding Key="Enter" Command="{Binding SelectItemCommand, Mode=OneTime}" />
        <KeyBinding Key="Tab" Command="{Binding SelectItemCommand, Mode=OneTime}" />
    </telerik:RadGridView.InputBindings>
</telerik:RadGridView>
Dilyan Traykov
Telerik team
 answered on 16 Nov 2020
8 answers
469 views

I am using "UI for WPF Q1 2016".

I am creating a RadDocument and I set the font to Calibri prior to adding anything:

         var doc = new RadDocument();
         // can't do real formatting without setting Paged
         doc.LayoutMode = DocumentLayoutMode.Paged;
         doc.Style.SpanProperties.FontSize = Unit.PointToDip(BodyFontSizePts);
         doc.Style.SpanProperties.FontFamily = new System.Windows.Media.FontFamily("Calibri");
Windows.Media.FontFamily("Calibri");

 

When I save as docx and open in Word, all is good.

When I open a modal dialog based on the RadRichTextBox, the ribbon bar says "Verdana".

When I save my multi-page document as PDF, the first page is obviously Verdana and the second page is obviously Calibri.

All I want is Calibri consistently throughout the document.

Thanks.

-John.

 

Reilly
Top achievements
Rank 1
Veteran
 answered on 13 Nov 2020
1 answer
241 views

Hello,

We have a gridview filled with production steps. These production steps can be reordered. For this we have implemented a behavior like the "Reorder Rows" behavior in your examples.These productions steps have a status field, that describe the step needs to be done or is done. the production steps will have to be processed from top to bottom 

The steps with status done do not need to be dragged and dropped, and the steps with status not done should never be dropped before a step with status done.

Is there a way to disable drag and drop for specific rows or cancel drop on specific rows?

Best regards and thanks for your help

Martin Ivanov
Telerik team
 answered on 13 Nov 2020
3 answers
620 views

Hi,

Is there any way to display the new NotifyIcon in an application that doesn't have any window?

I tried putting it in app.xaml like this:

<ResourceDictionary>
            <telerik:RadNotifyIcon x:Key="NotifyIcon"
                                   x:Name="NotifyIcon"         
                                   ShowTrayIcon="True"         
                                   TooltipContent="Test"         
                                   TrayIconSource="/TestNotifyIcon;component/SDK icon.ico"         
                                   GuidItem="020fea20-de2d-411f-87dd-111cd1e4f7fb">
            </telerik:RadNotifyIcon>
        </ResourceDictionary>

 

And then in App.xaml.cs:

public partial class App : Application
    {
        private RadNotifyIcon _taskbarIcon;
 
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
 
            _taskbarIcon = (RadNotifyIcon)FindResource("NotifyIcon");
        }
 
        protected override void OnExit(ExitEventArgs e)
        {
            if (_taskbarIcon != null)
                _taskbarIcon.Dispose();
 
            base.OnExit(e);
        }
    }

 

But the icon does not display...

We are currently using Hardcodet.NotifyIcon.Wpf package for this, and with that component this kind of code works, but we would like to use the Telerik component instead!

Regards
Andreas

Martin Ivanov
Telerik team
 answered on 13 Nov 2020
1 answer
192 views

Hi, I am new in telerik and (front-end). For my app I want to create dynamic Rad Cartisian chart ,fill it with scatter data points dynamically such that each data point should have predefined color. and store that dynamic created chart in tileview.

Problem is in assigning colors to each point. I would be very grateful if you can guide me in code.

  public RadTileViewItem CreateScatterPlotTile()
        {
            var chart = new Telerik.Windows.Controls.RadCartesianChart();
            var verticalaxis = new Telerik.Windows.Controls.ChartView.LinearAxis();
            var horizentalaxis = new Telerik.Windows.Controls.ChartView.LinearAxis();
            verticalaxis.Visibility = System.Windows.Visibility.Hidden;
            horizentalaxis.Visibility = System.Windows.Visibility.Hidden;

            chart.VerticalAxis = verticalaxis;

            chart.HorizontalAxis = horizentalaxis;

            ScatterPointSeries scatterSeries = new ScatterPointSeries();
            for (int i = 0; i < 100; i++)
            {
                ScatterDataPoint point = new ScatterDataPoint();
                point.XValue = xvaluelist[i];
                point.YValue = yvaluelist[i];
                scatterSeries.DataPoints.Add(point);
            }        
            chart.Series.Add(scatterSeries);
            var tile = new RadTileViewItem();
            tile.Content = chart;

            return tile;
        }  

 

Similarly I have color value list, How can I add colors from my list to each point.

Martin Ivanov
Telerik team
 answered on 12 Nov 2020
4 answers
241 views

How do I get StyleRules to work with a  DataTable as ItemSource of the GridView? 

 

I have some sample code that has two grid views with the same StyleRules but one uses DataTable and the other uses a list of object 'item'. The list of objects respects the StyleRules but the grid with the DataTable does not and I'm not sure why?

 

DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Value", typeof(int));
 
var dr = dt.NewRow();
dr["ID"] = 1;
dr["Value"] = 0;
dt.Rows.Add(dr);
 
dr = dt.NewRow();
dr["ID"] = 2;
dr["Value"] = 1;
dt.Rows.Add(dr);
 
dr = dt.NewRow();
dr["ID"] = 3;
dr["Value"] = 2;
dt.Rows.Add(dr);
  
RadGridView1.ItemsSource = dt;
 
 
List<Item> items = new List<Item>(){ new Item(1,0), new Item(2, 1) , new Item(3, 2) };
RadGridView2.ItemsSource = items;

 

<Grid>
<Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="*"/>
</Grid.RowDefinitions>
 
<TextBlock Grid.Row="1" FontSize="16" Margin="0,0,0,5" Text="Data Table Item Source"/>
<telerik:RadGridView Grid.Row="2" x:Name="RadGridView1" AutoGenerateColumns="False" ShowGroupPanel="False" >
    <telerik:RadGridView.RowStyleSelector>
        <telerik:ConditionalStyleSelector>
            <telerik:StyleRule Condition="Value > 1">
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="Background" Value="Red"/>
                </Style>
            </telerik:StyleRule>
            <telerik:StyleRule Condition="Value = 1">
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="Background" Value="Green"/>
                </Style>
            </telerik:StyleRule>
        </telerik:ConditionalStyleSelector>
    </telerik:RadGridView.RowStyleSelector>
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding ID}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Value}" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>
 
 
<TextBlock Grid.Row="3" FontSize="16" Margin="0,10,0,5" Text="List Object Item Source"/>
<telerik:RadGridView Grid.Row="4" x:Name="RadGridView2" AutoGenerateColumns="False" ShowGroupPanel="False"  >
    <telerik:RadGridView.RowStyleSelector>
        <telerik:ConditionalStyleSelector>
            <telerik:StyleRule Condition="Value > 1">
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="Background" Value="Red"/>
                </Style>
            </telerik:StyleRule>
            <telerik:StyleRule Condition="Value = 1">
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="Background" Value="Green"/>
                </Style>
            </telerik:StyleRule>
        </telerik:ConditionalStyleSelector>
    </telerik:RadGridView.RowStyleSelector>
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding ID}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Value}" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>
 
</Grid>
Richard
Top achievements
Rank 2
Iron
Iron
Veteran
 answered on 12 Nov 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
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
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
VirtualKeyboard
HighlightTextBlock
Security
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?