Telerik Forums
UI for WPF Forum
1 answer
367 views
Hello,

I'm using Telerik RadControls for WPF 2012.2.725.40. I have a RadListBox with a DataTemplate for the items. In the DataTemplate I have a TextBox and I want to achieve that when the user clicks inside the TextBox, the ListBoxItem gets selected. So, I made a Style:

<Style TargetType="{x:Type telerik:RadListBoxItem}">
    <Style.Triggers>
        <Trigger Property="IsKeyboardFocusWithin" Value="True">
            <Setter Property="IsSelected" Value="True" />
        </Trigger>
    </Style.Triggers>
</Style>

This works fine with standard WPF ListBox but not with RadListBox/RadListBoxItems.

The full source:
<Window x:Class="IsKeyboardFocusWithin.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <DataTemplate x:Key="ListBoxItemTemplate">
            <TextBox Text="aasdf asdf asdf asdf asf " />
        </DataTemplate>
 
        <Style TargetType="{x:Type ListBoxItem}">
            <Style.Triggers>
                <Trigger Property="IsKeyboardFocusWithin" Value="True">
                    <Setter Property="IsSelected" Value="True" />
                </Trigger>
            </Style.Triggers>
        </Style>
 
        <Style TargetType="{x:Type telerik:RadListBoxItem}">
            <Style.Triggers>
                <Trigger Property="IsKeyboardFocusWithin" Value="True">
                    <Setter Property="IsSelected" Value="True" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
     
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
         
        <ListBox x:Name="lstList" ItemTemplate="{StaticResource ListBoxItemTemplate}" VerticalContentAlignment="Stretch" ItemsSource="{Binding}"
                            SelectionMode="Single" />
 
        <telerik:RadListBox x:Name="lstTelerikList"
                            ItemTemplate="{StaticResource ListBoxItemTemplate}" VerticalContentAlignment="Stretch" ItemsSource="{Binding}"
                            SelectionMode="Single"
                            Grid.Row="1"/>
    </Grid>
</Window>

and the code-behind:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        Items = new ObservableCollection<string>() { "Item 1", "Item 2", "Item 3" };
        InitializeComponent();
        lstList.DataContext = Items;
        lstTelerikList.DataContext = Items;
    }
 
    public ObservableCollection<string> Items
    {
        get;
        set;
    }
}

Am I doing something wrong?
Masha
Telerik team
 answered on 03 Aug 2012
10 answers
326 views
I've got data loaded in the RadGridView control that I want to export to Excel. This is working just fine, using the .ToCSV method. However what I'm searching for is way to tell Excel to treat a column as a Text instead of General.

One of the columns is a bar code number. This number can start with a zero, like 0123456789.

After the export Excel cuts off the first zero because it is formatting it as a General and I get 123456789. I know I can reformat in Excel to custom format. But this should not be necessary.

Any recommendations?

I've tried setting DataFormatString to "{}{0:000000000000}", but this does not work. I did see a previous post that describes a bug in DataFormatString and I'm using 2010_1_0309 version of RadControls, which I think is a older version.

Thanks ...
Nikita
Top achievements
Rank 1
 answered on 03 Aug 2012
5 answers
499 views
Hi,

I'm trying to make a line chart with multiple series with the Y-Axis being an integer value and the X-Axis being a date value. However, I need to display something custom for the X-Axis item labels - not the date. So far I have been able to do everything except to get the X-Axis item labels to show the custom label values. Any help would be appreciated.

Thanks.
Rosko
Telerik team
 answered on 03 Aug 2012
2 answers
763 views
Hello!!

So, I blew up your ChartView by having fun with animating heights.  In my live application, I have two ChartViews on different rows of a Grid and the row heights are animated to show/collapse a chart.  If the window size is small enough, I will get a  "'-1' is not a valid value for property 'Height'." exception with this stack trace:
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.FrameworkElement.set_Height(Double value)
at Telerik.Windows.Controls.ChartView.PresenterBase.ArrangeUIElement(FrameworkElement presenter, RadRect layoutSlot, Boolean setSize) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Common\PresenterBase.cs:line 297
at Telerik.Windows.Controls.ChartView.CartesianChartGrid.UpdateYStripes() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\CartesianChartGrid.cs:line 479
at Telerik.Windows.Controls.ChartView.CartesianChartGrid.UpdateVisuals(ChartLayoutContext context) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\CartesianChartGrid.cs:line 421
at Telerik.Windows.Controls.ChartView.CartesianChartGrid.UpdateUICore(ChartLayoutContext context) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\CartesianChartGrid.cs:line 296

I have been able to reproduce this issue in its own project by forcefully setting the chart Height property to a small value and then adding a series (line/bar doesn't matter).  This is done in a Command executed by pressing a button.  Here is the relevant reproduction code:

View:
<Window x:Class="TinyChart.MainWindow"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
    <telerik:RadCartesianChart x:Name="chart" telerik:StyleManager.Theme="Metro">
        <telerik:RadCartesianChart.TrackBallInfoStyle>
            <Style TargetType="telerik:TrackBallInfoControl">
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock Text="{Binding}" Foreground="Black" HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </telerik:RadCartesianChart.TrackBallInfoStyle>
        <telerik:RadCartesianChart.Behaviors>
            <telerik:ChartTrackBallBehavior ShowIntersectionPoints="True" ShowTrackInfo="True" SnapMode="AllClosePoints" />
        </telerik:RadCartesianChart.Behaviors>
        <telerik:RadCartesianChart.HorizontalAxis>
            <telerik:DateTimeCategoricalAxis LabelFormat="dd MMM yyyy" Title="Date Processed" DateTimeComponent="DayOfYear" LabelFitMode="Rotate" LabelInterval="3" LastLabelVisibility="Visible">
                <telerik:DateTimeCategoricalAxis.LabelTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding}" HorizontalAlignment="Center" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:DateTimeCategoricalAxis.LabelTemplate>
            </telerik:DateTimeCategoricalAxis>
        </telerik:RadCartesianChart.HorizontalAxis>
        <telerik:RadCartesianChart.VerticalAxis>
            <telerik:LinearAxis Title="# Documents Processed" />
        </telerik:RadCartesianChart.VerticalAxis>
        <telerik:RadCartesianChart.Grid>
            <telerik:CartesianChartGrid MajorLinesVisibility="Y" StripLinesVisibility="Y" />
        </telerik:RadCartesianChart.Grid>
        </telerik:RadCartesianChart>
        <Button Command="{Binding MyCommand}" Width="64" Height="64" VerticalAlignment="Top" HorizontalAlignment="Right" Content="..." />
    </Grid>
</Window>

View Model:

public class MainWindowViewModel
    {
        public ObservableCollection<Item> Items { get; set; }
        public ICommand MyCommand { get; set; }
        public MainWindow View { get; set; }
 
        public MainWindowViewModel()
        {
            MyCommand = new RelayCommand(OnMyCommand);
 
            Items = new ObservableCollection<Item>();
 
            Items.Add(new Item { Date = DateTime.Now, Number = 1 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(1), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(2), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(3), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(4), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(5), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(6), Number = 0 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(1), Number = 1 });
            Items.Add(new Item { Date = DateTime.Now.AddDays(7), Number = 0 });
        }
 
        private void OnMyCommand()
        {
            View.chart.Height = 100;
            View.chart.Series.Add(new BarSeries
                        {
                            //StrokeThickness = 4,
                            //Stroke = Brushes.Red,
                            ItemsSource = Items,
                            CategoryBinding = new PropertyNameDataPointBinding("Date"),
                            ValueBinding = new PropertyNameDataPointBinding("Number"),
                            ShowLabels = false
                        });
        }
    }
 
    public class Item
    {
        public DateTime Date { get; set; }
        public int Number { get; set; }
 
        public override string ToString()
        {
            return Date.ToString() + " - " + Number.ToString();
        }
    }

I require this situation to work.  Although it may seem silly to set height before adding a series, this should not cause a crash.  If a workaround can't be found, I will require a hotfix.  This occurs with the latest version Q2 2012 SP1 (also Q1 2012).

The series is added after user invokes a command, so I know what data to display.  There can be multiple series in a chart also, hence the programmatic approach.

I am at a loss to figure out how to solve this problem as I can find nothing wrong with my code and it works fine when the screen size is sufficiently large enough.

Thank you very much!
Petar Kirov
Telerik team
 answered on 03 Aug 2012
1 answer
151 views
I'm trying to create a simple horizontal bar chart that contains 3 data items and corresponding values. I've been working through the Help files on the website to get started with a RadCartesianChart.
I have the dlls,  Telerik.Windows.Controls, Telerik.Windows.Controls.Chart, and Telerik.Windows.Data included as referenced libraries within the WPF project. Any ideas what I am doing wrong?

I have the following references setup in XAML:
xmlns:chart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart"
xmlns:charting="clr-namespace:Telerik.Charting;assembly=Telerik.Windows.Controls.Chart"
xmlns:chartView="clr-namespace:Telerik.Windows.Controls.ChartView;assembly=Telerik.Windows.Controls.Chart"

I have the chart declared as shown below. The LinearAxis and CategoricalAxis are displaying messages that state; The type 'chart:LinearAxis' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
<ContentControl Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="300"
                 x:Name="chartPlaceHolder">
    <chart:RadCartesianChart x:Name="speedometerChart">
        <chart:RadCartesianChart.HorizontalAxis>
            <chart:LinearAxis/>
        </chart:RadCartesianChart.HorizontalAxis>
        <chart:RadCartesianChart.VerticalAxis>
            <chart:CategoricalAxis/>
        </chart:RadCartesianChart.VerticalAxis>
    </chart:RadCartesianChart>
</ContentControl>
Rosko
Telerik team
 answered on 03 Aug 2012
2 answers
219 views
Hi there,

I've got the WPF telerik controls which is great, but I'm new to WPF so many of the controls and usages are still a bit of a mystery.
If I wanted a static main form and when different buttons (almost like a menu, but each button represents a section of the application) are clicked then I want to load another form into the main form, kind of like old MDI forms.

What's the right tool for the job here. I almost thought the Tileview might do the job, but then it seems more like the tile view is more there to dislpay small chunks of data to the user and have them be able to move it around.

Thanks,
Jacques
Jacques
Top achievements
Rank 2
 answered on 03 Aug 2012
3 answers
158 views
Hi,

I've been using the RowReordering tutorials to implement my drag & drop functionality and I'm trying to prevent certain grids from dropping their draggedItems into a grid. I'm thinking all I need is the target and source grid references, performing a simple comparison or test and show the "disabled" drag effect. I can get the target grid object but not the source grid object from inside the OnDragOver or OnDrop event handlers.

How can I do this? 

Thanks
Dimitrina
Telerik team
 answered on 03 Aug 2012
3 answers
141 views
Hi,

I'm trying to add an appointment to my ScheduleView using:

var appointments = new ObservableCollection<Appointment>();
Appointment myAppointment = 
new Appointment();
myAppointment.Subject = "Appointment Here";
myAppointment.Start = new DateTime(2012, 7, 31, 00, 00, 00);
myAppointment.End = new DateTime(2012, 7, 31, 2, 00, 00);
appointments.Add(myAppointment);
 
scheduleView.AppointmentsSource = appointments;

The above code works, but when I change the End date of myAppointment to  myAppointment.End = new DateTime(2012, 7, 31, 24, 00, 00); I'm getting a XamlParseException.

How should I be adding a 24hour appointment? Should it be just myAppointment.End = new DateTime(2012, 7, 31, 23, 59, 00);?


Thanks,
Mark
Mark
Top achievements
Rank 1
 answered on 03 Aug 2012
2 answers
187 views
I am using RadDataFilter in the following manner:
Just to build a list of conditions that users can query the database.

Our data is huge and thus we cannot bring all data and let the RadDataFilter control filter it. Rather, we are just using this control to get the list of conditions from the user, and then we query database to get the result set.

So, for example, if an element (column in the database) is of type "string (varchar)", I do not want to see all the options in the operator dropdown. Depending on what element is being filtered, I would want to display only certain operators.

Also, it would be nice to name the operators the way we want to. For example, I want to change the "is equal to" operator to something like "equals", and so on..
Shankar
Top achievements
Rank 1
 answered on 02 Aug 2012
2 answers
196 views
I am trying to store the "state" of the RadDataFilter in a database, so that the object can be persisted and the users can add/remove more filter expressions to it.

How is it possible? I tried to serialize the "FilterDescriptors" object, but is it the right way to do it? Is there a better solution than this?

Please let me know.
Shankar
Top achievements
Rank 1
 answered on 02 Aug 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
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?