Telerik Forums
UI for WPF Forum
1 answer
317 views

How I can export a table to a specific Excel sheet ?

 

<p>string file = this.radGridView.ToExcelML(objects, true);</p><p>File.WriteAllText("F:\\test.xls", file);</p>

 

The export works correctly. But I generates a file in a default sheet "WorkSheet" I would like to indicate the name of the sheet in the export.

Dilyan Traykov
Telerik team
 answered on 01 Aug 2016
1 answer
306 views

Hello,

  I try to set a dependency property in a gridviews custom column, based on GridViewBoundColumnBase, with binding to another field of my datasource. The problem is, that then the Int32 dependency property always is set with the int default value of 0 and not the actual value in my data. If I also show this field as additional column, I can see, that it is filled correct in the datasource.

When I set the dependency property with a fixed value (e.G. 2), this value is properly transferred to the custom column implementation. When I try binding, nothing is set in the custom column implementation. I also tried a nullable type for my property, than always the null value is set, if I try binding.

After intense internet research, studding examples and other people problems and resolutions, my implementation should work, but unfortunately it don't.

Here my code:

01.public class ActualValueInputColumn : GridViewBoundColumnBase
02.{
03.  public Int32 TestStepType
04.  {
05.    get { return (Int32) GetValue (TestStepTypeProperty); }
06.    set { SetValue (TestStepTypeProperty, value); }
07.  }
08.
09.  public static readonly DependencyProperty TestStepTypeProperty =
10.        DependencyProperty.Register ("TestStepType", typeof (Int32), typeof (ActualValueInputColumn), new PropertyMetadata (null));
11.
12.  public override FrameworkElement CreateCellEditElement (GridViewCell cell, object dataItem)
13.  {
14.    FrameworkElement picker = null;
15.    if (TestStepType == 0)
16.    {
17.      RadMaskedNumericInput numberPicker = new RadMaskedNumericInput ();
18.      numberPicker.SetBinding (RadMaskedNumericInput.ValueProperty, this.CreateValueBinding ());
19.      picker = numberPicker;
20.    }
21....
22.    else if (TestStepType == 2)
23.    {
24.      RadMaskedTextInput textPicker = new RadMaskedTextInput ();
25.      textPicker.SetBinding (RadMaskedTextInput.ValueProperty, this.CreateValueBinding ());
26.      picker = textPicker;
27.    }
28.
29.    return picker;
30.  }
31.
32.  public override object GetNewValueFromEditor (object editor)
33.  {
34.    ...
35.  }
36.
37.  private Binding CreateValueBinding ()
38.  {
39.    Binding valueBinding = new Binding ();
40.    valueBinding.Mode = BindingMode.TwoWay;
41.    valueBinding.NotifyOnValidationError = true;
42.    valueBinding.ValidatesOnExceptions = true;
43.    valueBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
44.    valueBinding.Path = new PropertyPath (this.DataMemberBinding.Path.Path);
45.
46.    return valueBinding;
47.  }
48.}

And by XAML (shortened):

 

01.<telerik:RadGridView x:Name="RadGridView1"
02.   telerik:StyleManager.Theme="Windows8Touch"
03.   ItemsSource="{Binding MeasuringMachineValues}"
04.   AutoGenerateColumns="False"
05.   ShowGroupPanel="False"
06.   IsFilteringAllowed="False"
07.   FontSize="18"
08.   CanUserDeleteRows="False"
09.   CanUserInsertRows="False">
10.  <telerik:RadGridView.Columns>
11.    <telerik:GridViewDataColumn Header="TestStepType"
12.             DataMemberBinding="{Binding TestStepType}"
13.             IsReadOnly="True"
14.    <qw:ActualValueInputColumn Header="Actual Value custom column"
15.             DataMemberBinding="{Binding ActualValueAsString, Mode=TwoWay}"
16.             TestStepType="{Binding TestStepType}"/>
17.    <telerik:GridViewDataColumn Header="Actual value standard"
18.             DataMemberBinding="{Binding ActualValueAsString}" />
19.  </telerik:RadGridView.Columns>
20.</telerik:RadGridView>

 

 

Please can anybody tell me, what is wrong with my implementation or even give me a hint, how to debug this binding to get a clue, where the problem is?

 

Greetings

  Thomas

Yoan
Telerik team
 answered on 01 Aug 2016
7 answers
218 views

Hi. I write C# WPF MVVM Prism 6 application. I'm interested in RadTreeListView with buttons-column there. I defined the folowing XAML for buttons-column in RadTreeListView:

<telerik:RadTreeListView x:Name="Hierarchical" Grid.Row="2" Grid.Column="0" AutoGenerateColumns="False" AutoExpandItems="True" IsSynchronizedWithCurrentItem="True"
                                     CanUserReorderColumns="False" CanUserSortColumns="False" CanUserSortGroups="False" CanUserDeleteRows="False" CanUserInsertRows="False"
                                     IsFilteringAllowed="False" EnableLostFocusSelectedState="False" RowIndicatorVisibility="Collapsed" SelectionUnit="FullRow"
                                     ItemsSource="{Binding DeviceProfile}" Visibility="{Binding AreRegistersInHierarchyVisible}" SelectedItem="{Binding SelectedProfileElement}"
                                     >
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
             <!--Button-column "Read current value from outer device selected register"-->
       <telerik:GridViewDataColumn IsVisible="{Binding IsReadColumnButtonVisible}">
           <telerik:GridViewDataColumn.CellTemplate>
               <DataTemplate>
                  <telerik:RadButton Margin="5" Content="Read Register Current Value" Visibility="{Binding IsSelected,
                                    RelativeSource={RelativeSource AncestorType={x:Type telerik:GridViewRow}}, Converter={StaticResource booleanToVisibilityConverter}}"
                                                   Command="{Binding InitializeRegisterCurrentValueReadingCommand}"/>
               </DataTemplate>
           </telerik:GridViewDataColumn.CellTemplate>
      </telerik:GridViewDataColumn>
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
</telerik:RadTreeListView>

I use your BooleanToVisibilityConverter in Prism UserControl where the RadTreeListView is:

<UserControl.Resources>
        <telerik:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/>
</UserControl.Resources>

Below is the source code of 'InitializeRegisterCurrentValueReadingCommand' command that is in View Model to which the Prism UserControl binds to:

// The command definition.
public DelegateCommand<object> InitializeRegisterCurrentValueReadingCommand { get; private set; }
 
// The command logic method.
private void initializeRegisterValueReading(object parameter)
{
    // My custom C# code
}
 
// The command CanExecute method.
private bool initializeRegisterValueReadingCanExecute(object parameter)
{
   // Some bolean condition is.
}
 
// Here is creating of command inside View Model constructor.
this.InitializeRegisterCurrentValueReadingCommand = new DelegateCommand<object>(this.initializeRegisterValueReading, this.initializeRegisterValueReadingCanExecute);

Please see the screnshot in 'RadTreeListView_with_buttons.PNG' file attached. Where "Прочитать значение из регистра" button is "Read Register Value" button and "Записать значение в регистр" button is "Write Value To Register" button. "InitializeRegisterCurrentValueReadingCommand' command is bound to "Read Register Value" button. But when I pess (click) this button the command doesn't fire! I also tryed the following notation in XAML:

<telerik:EventToCommandBehavior.EventBindings>
     <telerik:EventBinding
         Command="{Binding InitializeRegisterCurrentValueReadingCommand}"
         EventName="Click"
         PassEventArgsToCommand="True"/>
</telerik:EventToCommandBehavior.EventBindings>

But the result was the same pitiable-bad. But interestingly, when I create the handler of ButtonClick event (for button-cell) in code-behind, the the handler fires when the button is clicked! But  my application is pure MVVM application! So how do I make the command fire when user clicks the button? Either with such markup:

<telerik:GridViewDataColumn IsVisible="{Binding IsReadColumnButtonVisible}">
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <telerik:RadButton Margin="5" Content="Прочитать значение из регистра" Visibility="{Binding IsSelected,
                                    RelativeSource={RelativeSource AncestorType={x:Type telerik:GridViewRow}}, Converter={StaticResource booleanToVisibilityConverter}}"
                                                   Command="{Binding InitializeRegisterCurrentValueReadingCommand}"/>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

or with such markup:

<telerik:GridViewDataColumn IsVisible="{Binding IsReadColumnButtonVisible}">
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <telerik:RadButton Margin="5" Content="Прочитать значение из регистра" Visibility="{Binding IsSelected,
                                    RelativeSource={RelativeSource AncestorType={x:Type telerik:GridViewRow}}, Converter={StaticResource booleanToVisibilityConverter}}">
                                    <telerik:EventToCommandBehavior.EventBindings>
                                        <telerik:EventBinding
                                            Command="{Binding InitializeRegisterCurrentValueReadingCommand}"
                                            EventName="Click"
                                            PassEventArgsToCommand="True"/>
                                    </telerik:EventToCommandBehavior.EventBindings>
                                </telerik:RadButton>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

How do I make the command fire when user clicks the button? Please help solve the problem. Thank you very much in advance.

Dmitry
Top achievements
Rank 1
 answered on 01 Aug 2016
1 answer
166 views

Hi, 

I have following code: 

<telerik:RadScheduleView >
    <telerik:RadScheduleView.ViewDefinitions >
       <telerik:DayViewDefinition />
       <telerik:WeekViewDefinition />
    </telerik:RadScheduleView.ViewDefinitions>
      <telerik:RadScheduleView.GroupDescriptionsSource>
      <telerik:GroupDescriptionCollection>
          <telerik:DateGroupDescription  />
          <telerik:ResourceGroupDescription ResourceType="_StaffWorkplace" />
      </telerik:GroupDescriptionCollection>
    </telerik:RadScheduleView.GroupDescriptionsSource>
</telerik:RadScheduleView>

How I can hide some resource on certain date?  I tried to use GroupFilter, but it's work fine for me only for DayViewDefinition.

Regards,
Vladimir

Nasko
Telerik team
 answered on 01 Aug 2016
3 answers
134 views
hello,
Am using radchart in my wpf application, my requirement is based on Y axis value i have to set the different color for point marks in same line series chart.
for example am having values from 50 to 100, let say i want to set point mark Redfor values between 50 to 75, and remaining green in the same line series chart area..
 
please help to find the solution...

i have try the below option but it not works,,
foreach (var item in qry)
                    {
                        if(condition)
                        {
                        line.Appearance.Fill = new SolidColorBrush(Colors.Green);
                        }
                        else if (condition)
                        {
                            line.Appearance.Fill = new SolidColorBrush(Colors.Red);
                        }}
i need like this kind of effect in my wpf application ...

http://www.telerik.com/help/wpf/radchart-howto-set-custom-fill-for-pointmarks-depending-on-condition.html

my code below...
******************************
 public void chartmain()
        {
            listStackPanel.Visibility = System.Windows.Visibility.Hidden;
            try
            {
                
                var qry = (from s in SWindow.HBList
                           where (s.User_id.Equals(W.Profile.UserId))
                           orderby s.Test_date ascending
                           select new { s.HB_score, s.Test_date }).ToList();

                if (qry.Count == 0)
                {
                    SMessageBox.MessageBox.ShowInformation("No Records Found...");
                    radChart.Visibility = System.Windows.Visibility.Hidden;
                    listStackPanel.Visibility = System.Windows.Visibility.Hidden;
                }
                else
                {
                    

                   
                    radChart.Visibility = System.Windows.Visibility.Visible;
                    radChart.DefaultView.ChartArea.AxisX.IsDateTime = true;
                    radChart.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Auto;
                    radChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
                    radChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd-MMM";

                    DataSeries lineSeries1 = new DataSeries();

                    foreach (var item in qry)
                    {
                        SMessageBox.MessageBox.ShowInformation(item.ToString());
                        lineSeries1.Add(new DataPoint() {
                            YValue = Convert.ToDouble(item.HB_score), XValue = item.Test_date.ToOADate() 
                        
                        });

                       
                    }

                    

                    
                    LineSeriesDefinition line = new LineSeriesDefinition();
                    radChart.DefaultSeriesDefinition = line;

                    line.Appearance.Fill = new SolidColorBrush(Colors.Black);
                    line.Appearance.Stroke = new SolidColorBrush(Colors.DarkGreen);
                    line.Appearance.PointMark.Stroke = new SolidColorBrush(Colors.Black);
                    line.ShowPointMarks = true;
                    line.ShowItemLabels = true;
                    lineSeries1.Definition = line;


                    this.BHGridView.ItemsSource = qry;
                    this.radChart.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;

                     this.radChart.DefaultView.ChartArea.DataSeries.Add(lineSeries1);




                }
            }
            catch (Exception ex) {
                SMessageBox.MessageBox.ShowError(ex.Message);
            }
        }
       

Martin Ivanov
Telerik team
 answered on 01 Aug 2016
1 answer
136 views

I want to have a MarkerBrush based on a property of the data object being bound to. For example,

 

```

class MyDataPoint

{

   public DateTime XValue {get;set;}

   public double YValue {get;set;}

   public bool IsRed {get; set;}

}

```

 

I want all points where IsRed=true to be rendered red, and blue when false. Is it possible? 

I've made a Style with TargetType IndicatorItem and used DataTriggers but the style is always overridden with the default marker colour,

Evgenia
Telerik team
 answered on 29 Jul 2016
2 answers
79 views

Hi, I use a radgridview ,like this:

this.gridUserControl.gridview.ItemsSource = xmlElement.ChildNodes;

add a new dataitem to xmlElement...

this.gridUserControl.gridview.ItemsSource = xmlElement.ChildNodes; //rebinding

int i = gridUserControl.gridview.Items.Count;
XmlElement lastitem = (XmlElement)gridUserControl.gridview.Items[i - 1];
gridUserControl.gridview.SelectedItem = lastitem;
gridUserControl.gridview.BeginEdit();

 

I want to go in the edit status when add a new dataitem directly. It works well. But the problem is that I press any key the first time, the edit status will be ended. And the edit cell's value is the only the press key's value. That's inexplicable. Please help me to solve the problem ,thanks!

Jonathan
Top achievements
Rank 1
 answered on 29 Jul 2016
1 answer
476 views
Dear Telerik-Team,

we have a RadMenu that has bound his data over a ViewModel. Depending on the data we want to generate RadMenuGroupItems or RadMenuItems.
The bound data class is this:

public class MenuItem
    {
        public List<MenuItem> SubItems { get; set; }
        public string Text { get; set; }
        public Type EditUserControlType { get; set; }
        public Action<object> Navigate;
        public int RowIndex { get; set; }
        public int ColumnIndex { get; set; }

        public MenuItem()
        {
            SubItems = new List<MenuItem>();
        }
    }

if the MenuItem has SubItems we want that a RadMenuGroupItem is dynamically created. If the MenuItem has no SubItems we want that a RadMenuItem is created.
Is there a similar way of Item Creation like the dynamic assignemnt of Styles over the property "ItemContainerStyleSelector". We need something called "ItemContainerControlSelector"
but we didn't find anything in the documentation.

Important: We don't want to create the items dynamicalle in code behind of the view. We want to assign this logic via XAML in the View.

How can we do that?

Thanks for your help.

Kind regards
Polya
Telerik team
 answered on 29 Jul 2016
14 answers
547 views
Dear sir,

I am evaluating RadPropertyGrid for my application. 

First, please see a attached image.

I made a property class for the object.

public class MyProperty
{
private ObservableCollection<VideoProfile> videoProfiles;
public string a{ get; set; }
public string b{ get; set; }

public ObservableCollection<VideoProfile> VideoProfiles
        {
get {return videoProfiles;}
}
...
...
}

Than, I could see auto generated VideoProfiles Collection editor in run time.

Question.
1. I want to customize Collection editor style to VideoProfiles. Items section is displaying class path
2. I have referred the document, but It showed only image example about CollectionEditor, Can you give me a sample program about this? (Because it's first time that I develop a wpf application)
3. I want to use DataTemplateSelector to change properties of VideoProfiles. Because I need to show combobox for a property that should be selected in external items.

Best regards,

Stefan Nenchev
Telerik team
 answered on 29 Jul 2016
2 answers
400 views
Hi, I'm wondering how do I change the template such that there's a clear button within the Autocomplete box, something like how the radmaskinput box are.

[Search....           [x]]   <- AutocompleteBox
Nasko
Telerik team
 answered on 29 Jul 2016
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
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?