Telerik Forums
UI for WPF Forum
4 answers
300 views
Hi guys,

I'm actually displaying my RadGridView row details in a DetailPresenter (working withRadControls for WPF Q3 2012).
Each rows can be of different types, therefore, I use a template selector to display details. Templates are hosting user controls connected to ViewModels, instantiating in there own codebehind in onrender methods:

Mainwindow.xaml:
   
<Grid VerticalAlignment="Top">
       <Grid.Resources>
           <DataTemplate x:Key="KidDataTemplate">
                   <View:KidView KidId="{Binding Id}" />
           </DataTemplate>
           <DataTemplate x:Key="AdultDataTemplate">
                   <View:AdultView AdultId="{Binding Id}" />
           </DataTemplate>
           <selectors:UserDataTemplateSelector x:Key="UserDataTemplateSelector" />
       </Grid.Resources>
       <StackPanel Orientation="Vertical">
           <telerik:RadGridView x:Name="grid1"
                                    HorizontalAlignment="Left"
                                    Margin="10,10,0,0"
                                    VerticalAlignment="Top"
                                    RowDetailsTemplateSelector="{StaticResource UserDataTemplateSelector}"
                                    RowDetailsVisibilityMode="Collapsed"
                                    AutoGenerateColumns="True"/>
           <Border Grid.Row="1"  BorderBrush="WhiteSmoke" BorderThickness="5">
               <telerik:DetailsPresenter DetailsProvider="{Binding RowDetailsProvider, ElementName=grid1}" />
           </Border>
       </StackPanel>
   </Grid>

AdultView.xaml.cs:

public partial class AdultView : UserControl
    {
 
        public int? AdultId
        {
            get { return (int?)GetValue(AdultIdProperty); }
            set { SetValue(AdultIdProperty, value); }
        }
        public static readonly DependencyProperty AdultIdProperty = DependencyProperty.Register("AdultId", typeof(int?), typeof(AdultView));
         
        public AdultView()
        {
            InitializeComponent();
        }
         
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            if (AdultId.HasValue)
            {
                this.DataContext = new RowDetailSample.ViewModel.AdultViewModel(AdultId.Value);
            }
        }
 
    }


This works quite well until I'm selecting a second line of the same type:
The user control placed in the selected template does not update it's binding handled by its ViewModel.

Do I implement things correctly(is onrender method the right place to instanciate the viewModel object)? Do I miss something?

Thanks for your help.
Kind regards,
JC
Jc
Top achievements
Rank 1
 answered on 13 Nov 2012
1 answer
402 views
Hello,

How can I show a specific text string when a RadListBox instance is empty?

I tried defining a style to accomplish this goal, like this:

<Style TargetType="telerik:RadListBox" x:Key="ListStyle" BasedOn="{StaticResource {x:Type telerik:RadListBox}}">
    <Style.Triggers>
        <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" Value="0">
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="Margin" Value="0, 20, 0, 0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <TextBlock Foreground="DimGray" TextWrapping="Wrap" FontSize="14">
                            There are currently no items to show.
                        </TextBlock>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </DataTrigger>
    </Style.Triggers>
</Style>

I then attach it to the RadListBox instance:

<telerik:RadListBox  Style="{StaticResource ListStyle}">
   // items here
</telerik:RadListBox>

This actually works, for the most part... but it has a fatal flaw - the RadListBox scrollbars are no longer correctly themed.

Is there another way of accomplishing this goal? Or could I get some help in tweaking the style above so that the vertical scrollbar has the correct "Windows7" theme applied to it?
Masha
Telerik team
 answered on 13 Nov 2012
2 answers
345 views
Hi,

I made a categorical chart with a bar series definition and a line series definition. The x-axis label always seems to be the category name. How can I change it to something else? I have a custom class with various properties such as XValue, YValue, XCategory and Label. I have tried a few different things as suggested in other posts on the forum, but they don't seem to work and the item on the x-axis is always labelled according to the category.

I have tried setting the item label format in the series mapping (I tried #LABEL and "#DATAITEM.Label") and I have added the item mappings as well, but it still shows the XCategory instead of the label.

var seriesDefinition = new BarSeriesDefinition
            {
                ShowItemLabels = false,
                ShowItemToolTips = true,
                ItemToolTipFormat = "#DATAITEM.Label",
                ItemLabelFormat = "#DATAITEM.Label",
                EmptyPointBehavior = emptyPointBehavior
            };

seriesMapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));            
seriesMapping.ItemMappings.Add(new ItemMapping("XCategory", DataPointMember.XCategory));
seriesMapping.ItemMappings.Add(new ItemMapping("Label", DataPointMember.Label));

I have also tried the following:

chart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#DATAITEM.Label"; and chart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#LABEL"; 

Any help would be appreciated.
Petar Kirov
Telerik team
 answered on 13 Nov 2012
0 answers
127 views
  Hi EveryOne!
      i'm from china. person don't use English very often.
How to can the Controls language. pls look the pics.            
Zhang
Top achievements
Rank 1
 asked on 13 Nov 2012
6 answers
693 views
I am trying to change the track ball info, but I cannot figure out the right combination to get the data to come out the way I need it to come out. I want to show an identifier for a line series in much the same way that the ChartView demo does, but in that demo, the series and format strings are encoded into the XAML. In my app, there can be any number of line series, so they need to be created programmatically.

Here is the class that holds the data:
public class SalesInfo
{
    public string Employee { get; set; }
    public DateTime Time { get; set; }
    public int Value { get; set; }
}

And here is where I am creating the data and setting the item source of my line series:
data = new RadObservableCollection<SalesInfo>(data.OrderBy(x => x.Time));
 
Color dataColor = colorArray[loopCounter % 4];
 
LineSeries line = new LineSeries();
line.Stroke = new SolidColorBrush(dataColor);
line.StrokeThickness = 2;
line.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Time" };
line.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" };
line.ItemsSource = data;
var tbiTemplate = this.Resources["theTemplate"] as DataTemplate;
line.TrackBallInfoTemplate = tbiTemplate;
activitiesAddedChart.Series.Add(line);

And finally the template in the resources:
<DataTemplate x:Key="theTemplate">
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding DataPoint.SalesInfo.Employee}" />
        <TextBlock Text=": " />
        <TextBlock Text="{Binding DataPoint.Value}" />
    </StackPanel>
</DataTemplate>

I cannot figure out how to get this bound correctly so that I can see the Employee name in the track ball info. I get the Value fine, and if I use DataPoint.Category, I can get the date, but I just cannot figure out how to get the Employee to show up in that first TextBlock in the template. Thanks.

Tsvetie
Telerik team
 answered on 13 Nov 2012
1 answer
145 views
Hi, 
I use 2 screens and when I implement keytips they don't appear in the right position related to my application.
(I open up my application on my right screen, the "main display screen", but when I trigger the keytips they appear on my left screen...!)

Are there any settings I have to apply to "connect" the keytips to my application in any way...so that they always appear "in the right position" related to my app?

I've enabled keytips in my xaml and in the code-behind file I do this:
var keyGesture = new KeyGesture(Key.LeftAlt);
ribbon.SetValue(KeyTipService.AccessKeyProperty, keyGesture);
Stefan
Telerik team
 answered on 13 Nov 2012
3 answers
176 views

1.In the radrichtextbox , setting the page number, from 1 to N, it could be shown in the radrichtextbox correctly, but when calling window's printing function, all the pages's number is 1.

2.How to transter the Landscape of PrintDialog to the RadRichTectBox.

Robert
Top achievements
Rank 1
 answered on 12 Nov 2012
6 answers
395 views
Hi,

I am having trouble binding a class with 2 members to a RadGridView. The first member contains a dictionary to set the column header text and the second to fill the grid.

here is my sample project

cs

public Content()
{
      
    // Get the labels from database
    ContextSource.Labels = DictionaryFromDatabase();
    // Get grid data from database
    ContextSource.DataSrc = DataTableFromDatabase();
      
    Listing.DataContext = ContextSource;
}
  
public class ContextSource
{
  
    public DataTable DataSrc { get; set; }
    public Dictionary<string, string> Labels { get; set; }
      
    public ContextSource()
    {
        DataSrc = new DataTable();
        Labels = new Dictionary<string, string>;
    }
}

xaml
<telerik:RadGridView Margin="0"
                              
    AreRowDetailsFrozen="True"
    AutoGenerateColumns="False"
    CanUserFreezeColumns="False"
    IsReadOnly="True"
    ItemsSource="{Binding}" 
    SelectionMode="Single"
    ShowInsertRow="False"
    x:Name="Listing">
  
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="{Binding Labels.[str_label0]}" DataMemberBinding="{Binding Path=DataSrc.[columnname0]}"/>
        <telerik:GridViewDataColumn Header="{Binding Labels.[str_label1]}" DataMemberBinding="{Binding Path=DataSrc.[columnname1]}"/>
        <telerik:GridViewDataColumn Header="{Binding Labels.[str_label2]}" DataMemberBinding="{Binding Path=DataSrc.[columnname2]}"/>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

When I set Listing.DataContext = ContextSource, it will only fill the header text property. The grid is not populated.

If I direct the Listing.DataContent directly to ContextSource.DataSrc then the grid is populated, but the headers are not set.
Listing.DataContext = ContextSource.DataSrc;


Any idea what I am doing wrong?

Kind regards,
Dennis


Maya
Telerik team
 answered on 12 Nov 2012
1 answer
120 views

Hi,

 

I use the last (Q3 2012) version of WPF controls. And I noticed that it can't get  multilevel list (1.-1.1-1.1.1. for example)  as it would be expected.  The indent buttons behavior also doesn't work properly.

 

I would appreciate your advice or comments.

Igor


Vasil
Telerik team
 answered on 12 Nov 2012
5 answers
1.0K+ views
Hi There,

I'm finding myself a bit stumped as to how to set the position of the tabs on the tab control if the placement is set to go along the left or right as per the attached image.

what it does right now is place the tabs from the bottom going up, but i would prefer to have them go from the top down...

is there a way to set this??

Thanks,
Nemanja
Pavel R. Pavlov
Telerik team
 answered on 12 Nov 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?