Telerik Forums
UI for WPF Forum
1 answer
153 views
Hello. I need change theme dynamic. So I  added in reference dll from Binaries.NoXaml, and added resource dictionary into app.Resources
 <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="themes\System.Windows.xaml"/>
                <ResourceDictionary Source="themes\Telerik.Windows.Controls.Input.xaml"/>
                <ResourceDictionary Source="themes\Telerik.Windows.Controls.Navigation.xaml"/>
                <ResourceDictionary Source="themes\Telerik.Windows.Controls.RibbonView.xaml"/>
                <ResourceDictionary Source="themes\Telerik.Windows.Controls.RichTextBoxUI.xaml"/>
                <ResourceDictionary Source="themes\Telerik.Windows.Documents.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

reference dll 
Telerik.Windows.Controls.dll
Telerik.Windows.Controls.Input.dll
Telerik.Windows.Controls.Navigation.dll
Telerik.Windows.Controls.RibbonView.dll
Telerik.Windows.Controls.RichTextBoxUI.dll
Telerik.Windows.Data.dll
Telerik.Windows.Documents.dll

but   RadRichTextBoxRibbonUI dont show. if i add reference dll from Binary Folder then control display.


Andrew
Telerik team
 answered on 18 Jul 2012
1 answer
300 views
Hi

I am using a system in which I supply an object with a DataTepmlate.
The object has an interface which has a DataTemplate property (dynamic DataTemplate)

I apply an ItemTemplateSelector which returns the 'DataTemplate' Property

I also have a collection (Obserable) for these objects...

I Try to implement a SplitButton with a DropDownContent but I have 2 main problems.
1) The Menu appears but a MenuItem with childs only shows the Arrow but will not open not with click and with hover.
2) The MenuItems show`s an inner button, liks there the MenuItem and a RadButton inside....

This is my XAML:
SplitButton whereas local:SplitButtonVisualCommand is my business object.
<DataTemplate DataType="{x:Type local:SplitButtonVisualCommand}">
    <telerik:RadSplitButton Command="{Binding Command}" 
                            CommandParameter="{Binding GetParameters}"
                            Opacity="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource DisabledWorkAround}}"
                            IsToggle="{Binding RelativeSource={RelativeSource Self}, Path = IsOpen}"
                            DropDownContent="{Binding Childs}"   
                            DropDownContentTemplateSelector="{StaticResource VisualTempSelector}">
        <telerik:RadSplitButton.Content>
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding Image}" Margin="0 0 2 0"/> 
                <TextBlock Text="{Binding Caption}" />
            </StackPanel>                
        </telerik:RadSplitButton.Content>            
    </telerik:RadSplitButton>
</DataTemplate>
.
The 'Childs' DropDownContent is an Observable collection which returns the following DataTemplate:
(The Childs object also implement the 'DataTemplae' Property....)
<DataTemplate  DataType="{x:Type VisualCommands:VisualCommandCollection}">
    <telNav:RadContextMenu  ClickToOpen="False"
                            ItemsSource="{Binding}" 
                            ItemTemplateSelector="{StaticResource VisualTemplateSelector}"/>
</DataTemplate>

As you can see, it shows itself as a RadContextMenu (can be altered to RadMenu...) and sets itself as the ItemsSource as it holds the following Business Objects:

<DataTemplate DataType="{x:Type local:ContextMenuVisualCommand}">
    <telNav:RadMenuItem Header="{Binding Caption}"
                        Icon="{Binding Image}"
                        ItemsSource="{Binding Childs}"     
                        ItemTemplateSelector="{StaticResource VisualTemplateSelector}"
                        Command="{Binding Command}" 
                        CommandParameter="{Binding GetParameters}"
                        Opacity="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource DisabledWorkAround}}">
    </telNav:RadMenuItem>
</DataTemplate>

local:ContextMenuVisualCommand are the same as local:SplitButtonVisualCommand , they just have a different DataTemplate.
The present as RadMenuItem....

I`v attached an Image to visualize it...

The 1st menu item knows it has childs, but wont show them.
Also, what is this strange box inside the MenuItem? does it inhrit from the SplitButton?

I also know that
ItemTemplateSelector.SelectTemplate 
gets called Twice for each sub item in the SplitButton DropDownContent, this might explain the extra box inside the MenuItem.
This is strange becuase 'SelectTemplate' is called once for all other Business objects.

Also, 'SelectTemplate' is not called for the MenuItem inside the 1st MenuItem, which has logic since it never 'Show' it...
Thanks!
Shlomi.


Shlomi
Top achievements
Rank 1
 answered on 18 Jul 2012
1 answer
174 views
Hi guys,

I'm having a very weird problem, my current telerik version is 2011.2.920.35.

I'm parsing an XML file creating a list of objects which I'm binding to the grid, the type that implements IDataErrorInfo and it's functioning well, getting a list of errors where data is erroneous. 

The problem is that the rows are not highlighted red unless the erroneous cells are visible, so if the grid does not fit in screen, the erroneous records are displayed as normal until the user scrolls right. Once these records are highlighted red they will remain so even if the user scrolls back to left - however if the user scrolls right and scrolls down and back up, these records will not be red any more. See screenshot for explanation.

Any help will be greatly appreciated.

Thanks,
Daryl
Markus
Top achievements
Rank 1
 answered on 17 Jul 2012
2 answers
194 views
I have an object with custom properties. The only properties I wish to display in the property grid are those of category "MyCategory". How would I do that programatically?

protected string myproperty;
 
[Category("MyCategory")]
public string MyProperty{ get; set; }

I'm already setting the item and populating the RadPropertyGrid; it's the filtering I'm stuck on.

RadPropertyGrid1.Item = n;
Art Kedzierski
Top achievements
Rank 2
 answered on 17 Jul 2012
1 answer
277 views
Hi,

I am using RadListBox (Binded to ObservableCollection<string>) and when I navigate through the RadListbox using up and down keys, selectedItem changes automatically. How can I disable this behaviour? I only want to change SelectedItem only by pressing Enter Key or by Mouse's LeftClick in MVVM.
George
Telerik team
 answered on 17 Jul 2012
1 answer
338 views
In the chart I'm developing the user needs to be able to exclude or include series at runtime. 

If I have understood the information correctly so far it is not possible to XAML-declare series on this kind of dynamic sources but that it is something you're considering for a future update. I didn't want to do it all using code behind becuase that would mess up my ability to declare templates for each series and its trackball.

So, instead I build a small ChartBehavior that acts as the "glue" between my dynamic data series and the chart. It works as expected except for one detail: A series that gets omitted and then included again always ends up at the bottom of the trackball info popup. I assumed that the order of the items in the trackball popup was based on the physical order of the Chart.Series collection so the the behavior saves the initial order to be able to re-insert an omitted series at its original position but this does not work.

How can I affect the order of the items in the trackball info popup?

internal sealed class DynamicCategoricalSeriesBehavior : ChartBehavior
{
    private class SeriesInfo
    {
        public string SeriesKey { get; private set; }
        public int Index { get; set; }
 
        public SeriesInfo(string seriesKey, int seriesIndex)
        {
            Index = seriesIndex;
            SeriesKey = seriesKey;
        }
    }
    private Dictionary<CategoricalSeries, SeriesInfo> _categoricalSeries;
 
    protected override void OnAttached()
    {
        base.OnAttached();
        Chart.DataContextChanged += chartDataContextChanged;
        listenToDataContextPropertyChanged(Chart.DataContext as INotifyPropertyChanged);
    }
 
    protected override void OnChartTemplateChanged(Canvas oldAdornerContainer, Canvas adornerContainer)
    {
        base.OnChartTemplateChanged(oldAdornerContainer, adornerContainer);
        saveCategoricalSeriesValuePropertyNames();
        transformMetricsForSeries(Chart as RadCartesianChart);
    }
 
    private void saveCategoricalSeriesValuePropertyNames()
    {
        var cartesianChart = Chart as RadCartesianChart;
        if (cartesianChart == null)
            return;
 
        _categoricalSeries = new Dictionary<CategoricalSeries, SeriesInfo>();
        var seriesIndex = 0;
        foreach (var series in cartesianChart.Series)
        {
            var catSeries = series as CategoricalSeries;
            if (catSeries == null)
                continue;
 
            var propertyNameValueBinding = catSeries.ValueBinding as PropertyNameDataPointBinding;
            if (propertyNameValueBinding == null)
                continue;
 
            _categoricalSeries[catSeries] = new SeriesInfo(propertyNameValueBinding.PropertyName, seriesIndex++);
        }
    }
 
    private void chartDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
    {
        listenToDataContextPropertyChanged(Chart.DataContext as INotifyPropertyChanged);
    }
 
    private void listenToDataContextPropertyChanged(INotifyPropertyChanged vm)
    {
        if (vm == null)
            return;
 
        vm.PropertyChanged += (o, args) =>
        {
            if (args.PropertyName == "DynamicDataSeries")
                transformMetricsForSeries(Chart as RadCartesianChart);
        };
    }
 
    private void transformMetricsForSeries(RadCartesianChart chart)
    {
        if (chart == null)
            return;
 
        var dynamicVM = Chart.DataContext as IDynamicMetricsValueSeriesProvider<double>;
        if (dynamicVM == null)
            return;
 
        var supportedSeries = dynamicVM.DynamicDataSeries.Select(series => series.SeriesKey).ToList();
 
        foreach (var kvp in _categoricalSeries)
        {
            var series = kvp.Key;
            var seriesKey = kvp.Value.SeriesKey;
            if (!supportedSeries.Contains(seriesKey))
            {
                removeSeries(chart, series, seriesKey);
                continue;
            }
            insertSeries(chart, series, seriesKey, dynamicVM);
        }
    }
 
    private void insertSeries(RadCartesianChart chart, CategoricalSeries series, string key, IDynamicMetricsValueSeriesProvider<double> seriesProvider)
    {
        if (series.Visibility != Visibility.Visible)
        {
            series.Visibility = Visibility.Visible;
            var index = _categoricalSeries[series].Index;
            chart.Series.Insert(index, series);
        }
        var dataPoints = seriesProvider.MetricsData.Where(i => i.MetricsId == key).ToList();
        series.ValueBinding = new PropertyNameDataPointBinding("Value");
        series.ItemsSource = dataPoints;
        var stroked = series as CategoricalStrokedSeries;
        if (stroked != null)
            stroked.Stroke = seriesProvider.GetMetricsDataColorBrush(key);
    }
 
    private void removeSeries(RadCartesianChart chart, CategoricalSeries series, string key)
    {
        chart.Series.Remove(series);
        series.Visibility = Visibility.Collapsed;
    }
}


Giuseppe
Telerik team
 answered on 17 Jul 2012
1 answer
62 views
I Have a RadContextMenu in XAML in a RadTreeView that works fine. I dynamically load the tree items, and certain tree items I add a different Context menu, but it always opens the RadContextMenu in xaml. If I remove the xaml RadContextMenu ref, the dynamic ContextMenu loads.

So I guess is there a way to prevent every child from inheriting its parents context menu?

Thanks
Ivo
Telerik team
 answered on 17 Jul 2012
1 answer
393 views
I am using the RadGridView for a data entry screen (using MVVM), the last row is always empty and when the user starts to enter data into it a new row is added to the bottom on the list.  My issue is that once the itemSource is updated focus is taken out of the control and put into no mans land, making smooth data entry impossible.

The attached code is a cut down version of what i am doing and displays the same problem of lossing focus when the itemSource is updated.

XAML File
<Window x:Class="TelerikExample.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<DataTemplate x:Key="dtFirstName">
<TextBox Text="{Binding Path=FirstName, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}" />
</DataTemplate>
<DataTemplate x:Key="dtSecondName">
<TextBox Text="{Binding Path=SecondName, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}" />
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<telerik:RadGridView Grid.Row="1"
CanUserDeleteRows="False"
CanUserInsertRows="False"
CanUserSortColumns="False"
ShowGroupPanel="False"
AutoGeneratingColumn="RadGridView_AutoGeneratingColumn"
ItemsSource="{Binding Rows}"
RowIndicatorVisibility="Collapsed"
AlternateRowBackground="White"
AlternationCount="2"
Background="AliceBlue"
EditTriggers="None"
HorizontalGridLinesBrush="SlateGray"
SelectionMode="Single"
SelectionUnit="FullRow"
ShowColumnHeaders="True"
IsFilteringAllowed="False"
VerticalGridLinesBrush="Transparent">
</telerik:RadGridView>
</Grid>
</Window>


XMAL Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
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;
 
namespace TelerikExample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private GridViewModel _viewModel;
 
        public MainWindow()
        {
            InitializeComponent();
 
            _viewModel = new GridViewModel();
            this.DataContext = _viewModel;
        }
 
        private void RadGridView_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
        {
            if (e.Column.UniqueName == "FirstName")
            {
                e.Column.CellTemplate = (DataTemplate)this.Resources["dtFirstName"];
                e.Column.Header = "Forename";
            }
            else if (e.Column.UniqueName == "SecondName")
            {
                e.Column.CellTemplate = (DataTemplate)this.Resources["dtSecondName"];
                e.Column.Header = "Surname";
            }
            else if (e.Column.UniqueName == "ViewModel")
            {
                e.Column.IsVisible = false;
            }
        }
    }
}

View model file

namespace TelerikExample
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.Dynamic;
    using System.Collections.ObjectModel;
 
    public class GridViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private ObservableCollection<dynamic> _rows;
         
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        protected void OnPropertyChanged(string name)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
 
        public GridViewModel()
        {
            _rows = new ObservableCollection<dynamic>();
 
            var row = new ExpandoObject() as IDictionary<string, Object>;
 
            row.Add("FirstName", string.Empty);
            row.Add("SecondName", string.Empty);
            row.Add("ViewModel", this);
 
            ((INotifyPropertyChanged)row).PropertyChanged += new PropertyChangedEventHandler(TelerikExample.PropertyChanged.Row_PropertyChanged);
 
            _rows.Add(row);
        }
 
        public void CheckForNewRow()
        {
 
            IDictionary<string, Object> lastRow = _rows.Last() as IDictionary<string, Object>;
 
            if (((string)lastRow["FirstName"]) != string.Empty || ((string)lastRow["SecondName"]) != string.Empty)
            {
                //Add new row               
                var row = new ExpandoObject() as IDictionary<string, Object>;
 
                row.Add("FirstName", string.Empty);
                row.Add("SecondName", string.Empty);
                row.Add("ViewModel", this);
 
                ((INotifyPropertyChanged)row).PropertyChanged += new PropertyChangedEventHandler(TelerikExample.PropertyChanged.Row_PropertyChanged);
 
                this.Rows.Add(row);
            }
        }
 
        public ObservableCollection<dynamic> Rows
        {
            get
            {
                return _rows;
            }
            set
            {
                if (_rows != value)
                {
                    _rows = value;
                    OnPropertyChanged("Rows");
                }
            }
 
        }
    }
}

Property changed event

namespace TelerikExample
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.Dynamic;
 
    public class PropertyChanged
    {
        public static void Row_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            object value;
            ((IDictionary<string, Object>)sender).TryGetValue("ViewModel", out value);
            GridViewModel vm = (GridViewModel)value;
 
            vm.CheckForNewRow();
        }
    }
}

So my question is is there a way in which when the itemSource is updated focus isn't lost from the textbox.
Dimitrina
Telerik team
 answered on 17 Jul 2012
0 answers
109 views

I have the below code attached to a SelectionChanged event in a WPF RichTextBox. The idea is for it to select the sentence the user is currently editing, a la iAWriter. Any ideas why it only selects past the cursor, or occasionally throws a ArgumentNullException? Thanks in advance.

Regex sentence = new Regex(@"(([.?!][^\s])*[^.?!])*[.?!]\s"); 
Regex srtl = new Regex(@"(?:[.?!]\s)(([.?!][^\s])*[^.?!])*", RegexOptions.RightToLeft); 
TextRange all = new TextRange(GetPoint(inp.Document.ContentStart, 0), GetPoint(inp.Document.ContentEnd, 0)); 
TextRange aa = new TextRange(GetPoint(inp.Document.ContentStart, 0), GetPoint(inp.CaretPosition, 0)); 
TextRange ab = new TextRange(GetPoint(inp.CaretPosition, 0), GetPoint(inp.Document.ContentEnd, 0)); 
Match b = srtl.Match(aa.Text); 
Match c = sentence.Match(ab.Text); 
 
TextRange cur = new TextRange(GetPoint(inp.CaretPosition, -b.Index), GetPoint(inp.CaretPosition.GetPositionAtOffset(c.Index + c.Length + b.Length), 0)); 
all
.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Silver); 
cur
.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); 
Ja
Top achievements
Rank 1
 asked on 17 Jul 2012
1 answer
242 views
Hi

The idea is this: based on a dataset generated a tree structure but I found the following issues

1 - There is not a unique Key property by item or node... or is the property "Name"?
2 - Using the name property FindName method seems not to work ... so for items already included, this method always returns "Nothing" and the item is again included.

This process is generated immediately to the constructor of the class or window, ie, in the Sub Main exite a method that executes the code...

                    For Each currentRow As DataRow In myDataset.Tables(0).Rows

                        Dim currentItem As New RadTreeViewItem
                        With currentItem
                            .Header = currentRow("ObjectName").ToString.ToUpper.Trim
                            .IsEditable = False
                            .IsEnabled = True
                            .Name = .Header
                        End With

                        Dim myObject As RadTreeViewItem = Me.ObjectTypeTree.FindName(currentRow("ObjectName").ToString.ToUpper.Trim)

                        If myObject Is Nothing Then
                            Me.ObjectTypeTree.Items.Add(currentItem)
                        End If

currentItem  = Nothing
myObject  = Nothing

                    Next

 So how I can solve the case described in items 1 and 2.

In advance, thank you all ....
Tina Stancheva
Telerik team
 answered on 17 Jul 2012
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?