Telerik Forums
UI for WPF Forum
1 answer
115 views
Hi

We have a problem with ContextMenu in a textbox when we try to use it inside a DataFormDataField, the items doesn't appears, just appear "Copy, Cut, Paste".
We did try populate the ItemsSource property from Opening Event and from a Binding, but doesn´t work
I attached a little example solution

And here some code, the textbox outside DataForm works perfect
<Grid>
        <Grid.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Styles.xaml"/>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Grid.Resources>
       <telerik:RadDataForm x:Name="DataForm">
            <telerik:RadDataForm.ReadOnlyTemplate>
                <DataTemplate>
                <TextBox x:Name="textBox"
         Width="200" ContextMenu="{x:Null}"
         VerticalAlignment="Top" Margin="141,125,176,0">
                    <telerik:RadContextMenu.ContextMenu>
                        <telerik:RadContextMenu x:Name="ContextMenuHugo" ItemContainerStyle="{StaticResource MenuItemContainer}" Opening="ContextMenuHugo_OnOpening">
                                                   
                        </telerik:RadContextMenu>
                    </telerik:RadContextMenu.ContextMenu>
         
        </TextBox>
        </DataTemplate>
        </telerik:RadDataForm.ReadOnlyTemplate>
        </telerik:RadDataForm>
        <TextBox x:Name="textBox"
         Width="200" ContextMenu="{x:Null}"
         VerticalAlignment="Top" Margin="141,125,176,0">
            <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu x:Name="ContextMenuHugo" ItemContainerStyle="{StaticResource MenuItemContainer}"
                                                >
 
                </telerik:RadContextMenu>
            </telerik:RadContextMenu.ContextMenu>
 
        </TextBox>
    </Grid>

Thanks in advance
Boris
Telerik team
 answered on 14 Nov 2014
5 answers
85 views
Hello,

I am trying to use the CloudUpload within an ElementHost. When I choose a file and then click upload I get the following error:

Object reference not set to an instance of an object.
   at Telerik.Windows.Cloud.Controls.Upload.CloudUploadFile.UpdateCommandsCanExecute()
   at Telerik.Windows.Cloud.Controls.Upload.CloudUploadFile.SetState(CloudUploadFileState value)
   at Telerik.Windows.Cloud.Controls.Upload.CloudUploadFile.StartUpload()
   at Telerik.Windows.Cloud.Controls.RadCloudUpload.StartUpload(IEnumerable`1 items)
   ...

I'm setting up the CloudUpload like so:

            var upload = new RadCloudUpload();
            upload.Name = "radCloud1";
            upload.Provider = new DummyProvider();
            elementHost1.Child = upload;
 
 To confirm that I wasn't setting it up incorrectly I tried the same code without the element host and it works fine. Is the ElementHost unsupported?




Einar
Top achievements
Rank 1
 answered on 14 Nov 2014
7 answers
872 views

I want to put some text in the footer of a column in my gridview. However I can't get the binding to work.

 

I'm using MVVM. I have one viewmodel for the whole form including the gridview (let's call this MainViewModel) and also one viewmodel per row in the gridview (RowViewModel).

 

The text I want to show in the footer is in MainViewModel (let's call the property FooterText). How can I bind the text of the footer to this property?

 

My footer looks like this:

<telerikGridView:GridViewDataColumn.Footer>
    <TextBlock Text="Testing" />
</telerikGridView:GridViewDataColumn.Footer>

This example works and displays the text "Testing" in the footer. But my problems starts when I try to set the text using binding instead.

 

This doesn't work:

<telerikGridView:GridViewDataColumn.Footer>
    <TextBlock Text="{Binding Path=FooterText}" />
</telerikGridView:GridViewDataColumn.Footer>
I didn't expect this to work since all other properties of the column gets bound to the RowViewModel and not the MainViewModel. I'm guessing the same goes for the footer.

 

I've tried this:

<telerikGridView:GridViewDataColumn.Footer>
    <TextBlock Text="{Binding ElementName=LayoutRoot, Path=DataContext.FooterText}" />
</telerikGridView:GridViewDataColumn.Footer>

LayoutRoot is the Grid that is the root element of the form that the gridview resides in. This does not work. What confuses me is that I can bind the Header of the column in the exact way and it works:

<telerikGridView:GridViewDataColumn Header="{Binding ElementName=LayoutRoot, Path=DataContext.FooterText}" ... >

 

I've also tried this:

<telerikGridView:GridViewDataColumn.Footer>
    <TextBlock Text="{Binding Path=DataContext.FooterText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerikGridView:RadGridView}}" />
</telerikGridView:GridViewDataColumn.Footer>

This didn't work neither.

 

Any more ideas?

Vanya Pavlova
Telerik team
 answered on 14 Nov 2014
1 answer
39 views
When I have the following in my XAML code:

<Window.Resources>
   <my:MyViewModel x:Key="MyViewModel"/>
 
    <Style x:Key="CalendarStyle" TargetType="telerik:RadCalendar"
              BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Expression_DarkTheme, ElementType=telerik:RadCalendar}}">
      <Setter Property="AreWeekNumbersVisible" Value="False" />
    </Style>
 
    <Style TargetType="{x:Type telerik:RadDateTimePicker}" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Expression_DarkTheme, ElementType=telerik:RadDateTimePicker}}">
      <Setter Property="CalendarStyle">
          <Setter.Value>
          <Style BasedOn="{StaticResource CalendarStyle}" TargetType="telerik:RadCalendar">
          </Style>
        </Setter.Value>
      </Setter>
    </Style>
 
 
  </Window.Resources>
    <Grid DataContext="{StaticResource MyViewModel}">
    <telerik:RadGridView Grid.Row="0"
                             Name="clubsGrid"
                             ItemsSource="{Binding Clubs}"
                             AutoGenerateColumns="False"              
                             Margin="5">
            <telerik:RadGridView.Columns>  
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"
                                            Header="Est."
                                            DataFormatString="{}{0:yyyy/MM/dd}"
                                     />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding StadiumCapacity}"
                                            Header="Stadium"
                                            DataFormatString="{}{0:N0}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>


If I change AreWeekNumbersVisible to True, it works just fine. I am using telerik version 2013.3.1204.45.

See attached images.
Kalin
Telerik team
 answered on 14 Nov 2014
5 answers
284 views
I'm using Telerik DocumentSpellChecker together with a RadRichtextBox in a WPF-Application .

How do I do a case insensitive word comparison???
Petya
Telerik team
 answered on 14 Nov 2014
5 answers
269 views
Is it possible to use a ChartSeriesProvider with a CompositeCollection as the Source? Just specifying one as a StaticResource (which works fine for something like a ListBox that uses ItemsSource) results in an exception:
    Could not find property 'SeriesType' for type 'System.Windows.Data.CollectionContainer'

Example source of what I'm trying to do (modified version of the example Petar provided in this thread:

<Window x:Class="TwoDynamic.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <CollectionViewSource x:Key="FirstList" Source="{Binding Path=Series1}"/>
        <CollectionViewSource x:Key="SecondList" Source="{Binding Path=Series2}"/>
        <CompositeCollection x:Key="NewList">
            <CollectionContainer Collection="{Binding Source={StaticResource FirstList}}" />
            <CollectionContainer Collection="{Binding Source={StaticResource SecondList}}" />
        </CompositeCollection>
    </Window.Resources>
    <Grid>
        <telerik:RadCartesianChart>
            <telerik:RadCartesianChart.Resources>
                <Style TargetType="telerik:LineSeries">
                    <Setter Property="StrokeThickness" Value="2"/>
                    <Setter Property="Stroke" Value="Blue" />
                </Style>
                <Style TargetType="telerik:BarSeries">
                    <Setter Property="CombineMode" Value="None"/>
                </Style>
            </telerik:RadCartesianChart.Resources>
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis/>
            </telerik:RadCartesianChart.VerticalAxis>
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:DateTimeContinuousAxis LabelFitMode="Rotate" LabelFormat="MMM-dd" />
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:RadCartesianChart.SeriesProvider>
                <telerik:ChartSeriesProvider Source="{StaticResource NewList}">
                    <telerik:ChartSeriesProvider.SeriesDescriptors>
                        <telerik:CategoricalSeriesDescriptor ItemsSourcePath="Data" TypePath="SeriesType" CategoryPath="Date" ValuePath="Value"/>
                    </telerik:ChartSeriesProvider.SeriesDescriptors>
                </telerik:ChartSeriesProvider>
            </telerik:RadCartesianChart.SeriesProvider>
        </telerik:RadCartesianChart>
    </Grid>
</Window>

And the ViewModel:
namespace TwoDynamic
{
    public class DataPoint
    {
        public DateTime Date { get; set; }
        public double Value { get; set; }
    }
    public class SeriesBase
    {
        public ObservableCollection<DataPoint> Data { get; set; }
        public Type SeriesType { get { return SeriesTypeOverride; } }
        public virtual Type SeriesTypeOverride { get { return null; } }
    }
    public class PointData : SeriesBase
    {
        public override Type SeriesTypeOverride { get { return typeof(BarSeries); } }
    }
    public class LineData : SeriesBase
    {
        public override Type SeriesTypeOverride { get { return typeof(LineSeries); } }
    }
    public class ViewModel
    {
        private Random _Random = new Random();
        public ObservableCollection<SeriesBase> Series1 { get; private set; }
        public ObservableCollection<SeriesBase> Series2 { get; private set; }
        public ViewModel()
        {
            Series1 = new ObservableCollection<SeriesBase>();
            Series1.Add(new PointData() { Data = GenerateSomeData() });
            Series1.Add(new PointData() { Data = GenerateSomeData() });
            Series2 = new ObservableCollection<SeriesBase>();
            Series2.Add(new LineData() { Data = GenerateSomeData() });
            Series2.Add(new LineData() { Data = GenerateSomeData() });
        }
        private ObservableCollection<DataPoint> GenerateSomeData()
        {
            ObservableCollection<DataPoint> newCollection = new ObservableCollection<DataPoint>();
            for (int i = 0; i < 10; i++)
                newCollection.Add(new DataPoint() { Date = new DateTime(2012, 12, 31).AddDays(i), Value = _Random.Next(100) });
            return newCollection;
        }
    }
}
Petar Marchev
Telerik team
 answered on 14 Nov 2014
1 answer
138 views
Hi there. I am using a dataform to allow updates to a small class that contains a numeric value (specifically a decimal type).  The autogenerated field for the variable doesn't seem to be permitting me to input a decimal point. 

Any thoughts?
Boris
Telerik team
 answered on 14 Nov 2014
2 answers
137 views
Hi,

I am trying to display current time with an annotation, but it gets missplaced when the vertical scrollbar is shown (see screenshots).

I think the reason for the issue is that the VirtualizingTimelinePanel for annotation occupies the whole radtimeline width while the VirtualizingTimelinePanel for items is shrink by the ScrollViewer.

I am using the Windows8 theme.

Is this a known issue? Is there a workaround for it?

Best,

Ola
Ola
Top achievements
Rank 1
 answered on 13 Nov 2014
4 answers
168 views
During our evaluation of the RadMap control, we noticed that there is a significant delay (almost 1 second) between the mouse dragging and the starting of map panning.

I am using a local single image provider, so loading time shouldn't be the issue.

Is there any parameter I need to set to reduce this delay.
Ian
Top achievements
Rank 1
 answered on 13 Nov 2014
3 answers
93 views
Is there a way to change the background of the last column in GridView (attached image)

I have to display different number of columns based on some properties so i can not use Data binding, I ma creating the columns in code behind and also setting the width of columns.
In order to not have the last blank column i tried to set the width of last column to *, but when i do that the horizontal scroll bar do not appear if the content in the rows is bigger than the view can display

Here is the code i am using
/// <summary>
        /// Create the grid based on the list type
        /// </summary>
        private void InitializeGrid(csEnumListType listType)
        { 
            switch (listType)
            {
                case csEnumListType.csLstAppointmentTypes:
                    AddColumn("Description", 250, "GridDescription");
                    AddColumn("Abbreviation", 100, "ColumnValue1");
                    AddColumn("Appointment Category", 100, "ColumnValue2", true);
                    break;                
                case csEnumListType.csLstCollectors:
                case csEnumListType.csLstOperators:
                    AddColumn("Name", 400, "GridDescription");                    
                    AddColumn("Abbreviation", 85, "ColumnValue1", true);
                    break;
                case csEnumListType.csLstClmStyles:
                    AddColumn("Description", 300, "GridDescription");
                    AddColumn("Abbreviation", 100, "ColumnValue1");
                    AddColumn("Billing Media", 85, "ColumnValue2");
                    AddColumn("Claim Format", 100, "ColumnValue3", true, true);
                    break;
                default:
                    AddColumn("Description", 300, "GridDescription");
                    AddColumn("Abbreviation", 100, "ColumnValue1", true);                    
                    break;
            }            
        }

/// <summary>
        /// Add column with the header, width and binding
        /// </summary>
        /// <param name="col1Header"></param>
        /// <param name="col1Width"></param>
        private void AddColumn(string header, int width, string binding, bool isLastColumn = false, bool isClaimStyle = false)
        {
            GridViewDataColumn column = new GridViewDataColumn();
            column.DataMemberBinding = new Binding(binding);
            column.Header = header;
            column.TabStopMode = GridViewTabStop.Skip;
            column.Width = GridViewLength.Auto;

            this.RecordsGrid.Columns.Add(column);
        }

private void RecordsGrid_SourceUpdated(object sender, DataTransferEventArgs e)
        {
            if (RecordsGrid.Columns.Count > 0)
            {
                RecordsGrid.Columns[RecordsGrid.Columns.Count - 1].Width = new GridViewLength(100.123, GridViewLengthUnitType.Star);
            }
        }



Boris
Telerik team
 answered on 13 Nov 2014
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?