Telerik Forums
UI for WPF Forum
2 answers
163 views
I am trying to do MVVM with data binding to GraphSource using a ObservableGraphSourceBase.  When I drop a container from the DiagramToolbox.  How would be able to associate that container with view model item and still be able to undo or redo adding that item to the diagram?
Kent
Top achievements
Rank 1
 answered on 22 Aug 2013
1 answer
274 views
Hello,

I'm wondering how I can let a header do texttrimming?
In the picture below, you can see that my column values are being trimmed, but the header text isn't..

http://imageshack.us/photo/my-images/843/jrsp.png/

Thanks!
Yoan
Telerik team
 answered on 22 Aug 2013
4 answers
276 views
Hi,

how can i add a errorhandling to a RadMaskedTextInput? On LostFocus-Event i check if the Input is ok or not. If the
Input is not ok, i want to clear the RadMaskedTextInput and set the Cursor back in the box.

To clear is no problem:

RadMaskedTextInput.Text = "";

But how to set the Focus?

RadMaskedTextInput.Focus(); does not work.

Thanks Best Regards
Rene
Diego
Top achievements
Rank 1
 answered on 22 Aug 2013
0 answers
57 views

the above code giving the error as "The Resource 'Localized strings ' could't be resolved

<TelerikPopup:GridViewComboBoxColumn.Header>
                                                                <TextBlock Text="{Binding Source={StaticResource localizedStrings}, Path=LabelString.LocalizationResources.UOM, FallbackValue='UOM'}"/>
                                                            </TelerikPopup:GridViewComboBoxColumn.Header>
How to Resolve it


Pranavi
Top achievements
Rank 1
 asked on 22 Aug 2013
1 answer
253 views
How do I prevent the selction changed event from firing when a listbox item is selected for drag drop?

The main WPF form contains the RadDock. The RadDock has a RadPaneGroup that is docked left. RadPanes containing RadListBox controls are added to this RadPaneGroup based on user selection, an example being a list of customers.

The RadDock has a second RadPaneGroup, and this RadPaneGroup is in the DocumentHost property of the RadDock so that its RadPanes open as tabbed documents.

An example of normal behavior is that a RadListbox containing a list of customers appears in a RadPane that is in the docked left RadPaneGroup. A user selects a specific customer from the list, the selection changed event fires, and the application adds a RadPane to the Document host RadPaneGroup so that details about the selected customer are shown as a tabbed document.

One of the user actions is to create a shopping cart. A menu option is chosen and a RadPane containing the shopping cart information is added to the DocumentHost RadPaneGroup. The first thing that a user needs to do is associate a customer to the shopping cart. The idea is that the user would drag a customer from the RadListbox contained in a docked left RadPane onto the RadPane that is in the document host RadPaneGroup and shown as the currently active tabbed document.

My problem is that when I left click and hold down the mouse button to drag an item out of the RadListbox that is in the docked left RadPaneGroup, the RadListbox selection changed event fires, which then opens a customer details RadPane in the tabbed document DocumentHost area; the shopping cart is no longer visible because it is no longer the active tab.

The desired behavior is that the RadListbox selection changed event does not fire during a drag / drop operation so that I can drag the selected customer from the RadListbox contained within the docked left RadPane onto the empty shopping cart RadPane that is displayed as a tabbed document in the DocumentHost.

Do you have any vb.net examples, or documentation that would explain the desired behavior?
Rosen Vladimirov
Telerik team
 answered on 22 Aug 2013
0 answers
167 views
Hello, i'll wrote my app with mvvm pattern and have a problem with selecting item programmatically in resourcedictionary.
I have TreeListView on the one resourcedictionary and GridView in another. Also I have two ObservableCollection 1 and 2 wich i bind.
When user select item in the TreeListView and this item has a reference to another items at this (1) then i add referenced items to anothe ObservableCollection (2). GridView bind to the ObservableCollection (2) and when the user select item from GridView 
at the ObservableCollection (2) I find the same item in ObservableCollection (1) and set the "SelectedItem" to it and the problem is that the  TreeListView didn't Expand parents to the SelectedItem. Help me pleas! Attached example below.
Best Regards,
Dmytro.









Dmytro
Top achievements
Rank 1
 asked on 22 Aug 2013
8 answers
212 views
Hi,

i'm using the "Grouping and Filterung" Example of SchduleVIew. Ther you Add the ResourceTypesSource in xaml.
How do i add the Resources by code behind in this case?

XAML:
<scheduleView:RadScheduleView.ResourceTypesSource>
      <scheduleView:ResourceTypeCollection>
             <scheduleView:ResourceType Name="Category">
                        <scheduleView:Resource ResourceName="Sven Ottlieb" />
                        <scheduleView:Resource ResourceName="Martine Rance" />
                        <scheduleView:Resource ResourceName="Howard Snyder" />
                        <scheduleView:Resource ResourceName="Daniel Tonini" />
                        <scheduleView:Resource ResourceName="John Steel" />
              </scheduleView:ResourceType>
       </scheduleView:ResourceTypeCollection>
</scheduleView:RadScheduleView.ResourceTypesSource>

Code Behind?
Thanks
Best Regrds
Kalin
Telerik team
 answered on 22 Aug 2013
0 answers
131 views
I have used RadChart for displaying graph, On legend i have used chekboxes for each item. upon which the respective series will be show/hide.On opening the form the data is loaded and legend items are checked by default. The problem is that when i unchecked the items and then scroll the chart or zoom in the checboxes are automatically checked, although the series are hidden as i have already uncheck the items.Why the checkboxes are automatically got checked on zooming or scrolling.I want the checkboxes to remain unchecked

User control class

public partial class UserControl1 : UserControl
    {
        DataSeries lineSeries;
        SeriesMapping seriesMapping;
        SeriesDefinition seriesDefinition;
        vm objvm;
        List<Data> vitalSign;
        List<CheckBox> VSChk;
        public Dictionary<object, bool?> chkbxState;
        
        public UserControl1()
        {
            InitializeComponent();
            radChart1.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Between;
            radChart1.DefaultView.ChartArea.AxisX.AxisLabelsVisibility = Visibility.Hidden;
            //radChart1.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
            radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
            radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.2;
            radChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = true;
           
             
        }
 
        public void initViewModel()
        {       
            objvm = ((vm)this.FindResource("ViewModel"));
            vitalSign = new List<Data>();     
        }
        public void addData(string XValue, string YValue, string VSCode, string EncounterDate)
        {
            vitalSign.Add(new Data(DateTime.Parse(XValue), double.Parse(YValue), VSCode, DateTime.Parse(EncounterDate)));
        }
        public void setSeriesMapping()
        {
           // List<Data> vs;
            try
            {
                var v1 = (from c1 in vitalSign
                          select new { itemCode = c1.vsCode }).Distinct().ToList();
 
                foreach (var item in v1)
                {
                   // vs = new List<Data>();
                    seriesMapping = new SeriesMapping();
                    seriesDefinition = new LineSeriesDefinition();
                    seriesDefinition.ShowItemToolTips = true;
                    seriesMapping.LegendLabel = item.itemCode;
                    seriesMapping.SeriesDefinition = seriesDefinition;
                    seriesMapping.SeriesDefinition.Visibility = SeriesVisibility.Visible;
 
                    var v2 = from c2 in vitalSign
                             where c2.vsCode == item.itemCode
                             select c2;
 
                    seriesMapping.ItemMappings.Add(new ItemMapping("encounterDate", DataPointMember.XCategory));
                    seriesMapping.ItemMappings.Add(new ItemMapping("Y", DataPointMember.YValue));
                    seriesMapping.ItemMappings.Add(new ItemMapping("toolTip", DataPointMember.Tooltip));
 
                    /*foreach (var vitalsign in v2)
                    {
                        vs.Add(new Data(vitalsign.X, vitalsign.Y, vitalsign.vsCode, vitalsign.encounterDate));
                    }
                     */
                    objvm._mapping.Add(seriesMapping.LegendLabel, seriesMapping);
                   // seriesMapping.ItemsSource = vs;
                    seriesMapping.ItemsSource = v2.ToList();
                    radChart1.SeriesMappings.Add(seriesMapping);
                }
 
            }
            catch (Exception ex)
            {
 
            }
        }     
        public void setData(string controlname)
        {
            // not use now
            try
            {
                seriesMapping = new SeriesMapping();
                seriesDefinition = new LineSeriesDefinition();
                seriesDefinition.ShowItemToolTips = true;
                seriesMapping.LegendLabel = controlname;
                seriesMapping.SeriesDefinition = seriesDefinition;
                seriesMapping.SeriesDefinition.Visibility = SeriesVisibility.Visible;              
               // seriesMapping.ItemMappings.Add(new ItemMapping("X", DataPointMember.XValue));
                seriesMapping.ItemMappings.Add(new ItemMapping("X", DataPointMember.XCategory));
                seriesMapping.ItemMappings.Add(new ItemMapping("Y", DataPointMember.YValue));
                seriesMapping.ItemMappings.Add(new ItemMapping("toolTip", DataPointMember.Tooltip));
 
                seriesMapping.ItemsSource = this.vitalSign;
                 
                objvm._mapping.Add(seriesMapping.LegendLabel, seriesMapping);             
                radChart1.SeriesMappings.Add(seriesMapping);
            }
            catch  (Exception ex)
            {
             
            }
        }   
        public void setDataLineSeries()
        {
            try
            {
                var v7 = (from c7 in vitalSign
                          select new { itemCode = c7.vsCode }).Distinct().ToList();
                 
                foreach (var item in v7)
                {
                    lineSeries = new DataSeries();
                    lineSeries.Definition = new LineSeriesDefinition();
                    lineSeries.Definition.ShowItemToolTips = true;
                    lineSeries.LegendLabel = item.itemCode;
 
                    var v8 = from c8 in vitalSign
                             where c8.vsCode == item.itemCode
                             select c8;
 
                    foreach (var vitalsign in v8)
                    {
                        lineSeries.Add(new DataPoint() { XCategory = vitalsign.encounterDate.ToString("g"), YValue = vitalsign.Y, Tooltip = vitalsign.toolTip });
                    }
                   // objvm._series.Add(lineSeries.LegendLabel, lineSeries);
                    radChart1.DefaultView.ChartArea.DataSeries.Add(lineSeries);
                   
                }
            }
            catch (Exception ex)
            {
 
            }
        }
        private void RadChart1_Loaded(object sender, RoutedEventArgs e)
        {
           /* List<CheckBox> checkBoxes = radChart1.DefaultView.ChartLegend.ChildrenOfType<CheckBox>().ToList<CheckBox>();
            if (checkBoxes.Count > 0)
            {
                checkBoxes[0].IsEnabled = false;
            }
            //       SetSeriesItemStyle();
            */
        }
        public void getchkbxControl()
        {
            VSChk = new List<CheckBox>();
            var mapping = radChart1.SeriesMappings;
            try
            {
                for (int i = 0; i < mapping.Count; i++)
                {
                    ChartLegendItem legendItem = (radChart1.DefaultView.ChartLegend as System.Windows.Controls.ItemsControl).Items[i] as ChartLegendItem;
                    CheckBox checkBox = legendItem.ChildrenOfType<CheckBox>().FirstOrDefault();
                    VSChk.Add(checkBox);
                }
            }
            catch (Exception ex)
            {
 
            }
        }
 
        private void AxisX_RangeChanged(object sender, EventArgs e)
        {
            try
            {
                if (VSChk != null)
                {
                    foreach (var item in VSChk)
                    {
                        item.IsChecked = chkbxState[item.Content].Value;
                    }
                }            
            }
            catch (Exception ex)
            { }
        }
 
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        
            chkbxState = new Dictionary<object, bool?>();
            foreach (var item in VSChk)
            {          
                chkbxState.Add(item.Content, item.IsChecked);
            }
        }
 
        private void ChartArea_Loaded(object sender, RoutedEventArgs e)
        {
            
        }
        
        private void post_Unchecked(object sender, RoutedEventArgs e)
        {
            chkbxState = new Dictionary<object, bool?>();
            foreach (var item in VSChk)
            {
                chkbxState.Add(item.Content, item.IsChecked);
            }
        }
    }
   

here is the XAML code

<UserControl x:Class="HMVitalSignGraph.UserControl1"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:example="clr-namespace:HMVitalSignGraph"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="500">
 
    <UserControl.Resources>
        <example:vm x:Key="ViewModel" />
        <Style x:Key="SeriesItemLabelStyle"
        TargetType="telerik:SeriesItemLabel">
            <Setter Property="HorizontalContentAlignment"
            Value="Center" />
            <Setter Property="Padding"
            Value="2,0" />
            <Setter Property="Foreground"
            Value="Black" />
            <Setter Property="FontWeight"
            Value="Bold" />
            <Setter Property="FontFamily"
            Value="Trebuchet MS" />
            <Setter Property="FontSize"
            Value="12" />
        </Style>
         
        <Style x:Key="CustomLegendItemStyle" TargetType="telerik:ChartLegendItem">
            <Setter Property="Template" >
                <Setter.Value>
                     
                    <ControlTemplate TargetType="telerik:ChartLegendItem">
                        <Grid x:Name="PART_MainContainer" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,5,0">
                            <Path x:Name="PART_LegendItemMarker"
                                  Height="20"
                                  Width="150"
                                  Style="{TemplateBinding ItemStyle}"
                                  Stretch="UniformToFill">
                                <Path.Data>
                                    <PathGeometry x:Name="PART_ItemMarkerGeometry" />
                                </Path.Data>
                            </Path>
                             
                            <CheckBox x:Name="post" IsChecked="True"
                                      Foreground="Black"
                                      VerticalAlignment="Center"
                                      Margin="2,0"
                                      Content="{TemplateBinding Label}"                                 
                                      Background="{TemplateBinding Background}"
                                      Command="{Binding Path=ChangeSeriesVisibilityCommand, Source={StaticResource ViewModel}}"
                                      CommandParameter="{TemplateBinding Label}" Checked="CheckBox_Checked" Unchecked="post_Unchecked" />
                        </Grid>
 
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Canvas x:Name="canv" Background="#edf7ff">
        <Grid Width="{Binding ActualWidth, ElementName=canv}"  Height="{Binding ActualHeight, ElementName=canv}" MinWidth="1">
            <telerik:RadChart Name="radChart1" DataContext="{Binding}"  HorizontalAlignment="Left" telerik:StyleManager.Theme="Windows7" Loaded="RadChart1_Loaded"  VerticalAlignment="Top" >
                <telerik:RadChart.DefaultView>
                    <telerik:ChartDefaultView  ChartLegendPosition="Right">
                        <!--<telerik:ChartDefaultView.ChartTitle>
                        <telerik:ChartTitle>CDC growth chart</telerik:ChartTitle>
                    </telerik:ChartDefaultView.ChartTitle>-->
                        <telerik:ChartDefaultView.ChartLegend>
                            <telerik:ChartLegend x:Name="PrimaryLegend" Header="Click on vital signs to hide/show:" LegendItemMarkerShape="Square" LegendItemStyle="{StaticResource CustomLegendItemStyle}"  />
                        </telerik:ChartDefaultView.ChartLegend>
                        <telerik:ChartDefaultView.ChartArea >
                            <telerik:ChartArea  SmartLabelsEnabled="True" EnableAnimations="False" Padding="5,10,20,5" LabelFormatBehavior="HumanReadable"    LegendName="PrimaryLegend" FontSize="10" Loaded="ChartArea_Loaded" >
                                <telerik:ChartArea.AxisX>
                                    <telerik:AxisX  RangeChanged="AxisX_RangeChanged"  />
                                </telerik:ChartArea.AxisX>
                                <!--<telerik:ChartArea.AxisY>
                                    <telerik:AxisY ExtendDirection="None"  />
                                </telerik:ChartArea.AxisY>-->
                            </telerik:ChartArea>
                        </telerik:ChartDefaultView.ChartArea>
                    </telerik:ChartDefaultView>
                </telerik:RadChart.DefaultView>
            </telerik:RadChart>
        </Grid>
    </Canvas>
</UserControl>

View model class

class vm : ViewModelBase
    {
        public Dictionary<string, SeriesMapping> _mapping = new Dictionary<string, SeriesMapping>();
        //public Dictionary<string, DataSeries> _series = new Dictionary<string, DataSeries>();
        private ICommand _changeSeriesVisibilityCommand;
     
        public SeriesMapping this[string name]
        {
            get
            {
                return _mapping[name];
            }
            set
            {
                _mapping[name] = value;
            }
        }    
       /* public DataSeries this[string name]
        {
            get
            {
                return _series[name];
            }
            set
            {
                _series[name] = value;
            }
        }
        */
        public vm()
        {
            this.WireCommands();
        }
        public void WireCommands()
        {
            this.ChangeSeriesVisibilityCommand = new DelegateCommand(this.ChangeSeriesVisibility);
        }
        public ICommand ChangeSeriesVisibilityCommand
        {
            get
            {
                return this._changeSeriesVisibilityCommand;
            }
            private set
            {
                this._changeSeriesVisibilityCommand = value;
            }
        }
        public void ChangeSeriesVisibility(object parameter)
        {
            try
            {
                string parm = parameter.ToString();
 
                if (this._mapping[parm].SeriesDefinition.Visibility == SeriesVisibility.Collapsed || this._mapping[parm].SeriesDefinition.Visibility == SeriesVisibility.Hidden)
                    this._mapping[parm].SeriesDefinition.Visibility = SeriesVisibility.Visible;
                else
                    this._mapping[parm].SeriesDefinition.Visibility = SeriesVisibility.Hidden;
                 
               /* if (this._series[parm].Definition.Visibility == SeriesVisibility.Collapsed || this._series[parm].Definition.Visibility == SeriesVisibility.Hidden)
                    this._series[parm].Definition.Visibility = SeriesVisibility.Visible;
                else
                    this._series[parm].Definition.Visibility = SeriesVisibility.Hidden;
                */
            }
            catch (Exception ex)
            {
 
                throw;
            }
        }
    }

WPF application class

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            userControl11.initViewModel();
            userControl11.addData(DateTime.Now.ToString("g"), "10", "Diasystolic blood pressure", DateTime.Now.ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(2).ToString("g"), "20", "Diasystolic blood pressure", DateTime.Now.ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(4).ToString("g"), "30", "Diasystolic blood pressure", DateTime.Now.AddDays(2).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(6).ToString(), "40", "Diasystolic blood pressure", DateTime.Now.AddDays(2).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(8).ToString(), "50", "Diasystolic blood pressure", DateTime.Now.AddDays(2).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(10).ToString(), "60", "Diasystolic blood pressure", DateTime.Now.AddDays(4).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(11).ToString(), "70", "Diasystolic blood pressure", DateTime.Now.AddDays(4).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(12).ToString(), "80", "Diasystolic blood pressure", DateTime.Now.AddDays(6).ToString("g"));
       
            userControl11.addData(DateTime.Now.AddDays(1).ToString(), "10", "Pulse rate", DateTime.Now.AddDays(1).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(3).ToString(), "60", "Pulse rate", DateTime.Now.AddDays(1).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(5).ToString(), "90", "Pulse rate", DateTime.Now.AddDays(3).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(7).ToString(), "20", "Pulse rate", DateTime.Now.AddDays(3).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(9).ToString(), "110", "Pulse rate", DateTime.Now.AddDays(5).ToString("g"));
 
            userControl11.addData(DateTime.Now.AddDays(1).ToString(), "5", "rate", DateTime.Now.ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(3).ToString(), "15", "rate", DateTime.Now.AddDays(1).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(5).ToString(), "25", "rate", DateTime.Now.AddDays(5).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(7).ToString(), "35", "rate", DateTime.Now.AddDays(5).ToString("g"));
            userControl11.addData(DateTime.Now.AddDays(9).ToString(), "45", "rate", DateTime.Now.AddDays(7).ToString("g"));
 
            userControl11.setSeriesMapping();
               
        }
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            userControl11.getchkbxControl();
        }
Muhammad
Top achievements
Rank 1
 asked on 22 Aug 2013
1 answer
108 views
Binding a view model property to the SearchText property of a RadAutoCompleteBox seems to have no effect (when typing in the RadAutoCompleteBox, the view model property remains null).

Is this by design? Is there a workaround?
cocowalla
Top achievements
Rank 1
 answered on 22 Aug 2013
2 answers
186 views
Hi,
Is there a way of setting the ZIndex of a CustomGridLine?
I have a BarSeries with two CustomGridLines and I want the GridLines to be over the bar.
The way it is now is that the bar is over the GridLines.

See attached image.

Thanks in advance.
Ye
Top achievements
Rank 1
 answered on 22 Aug 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?