Telerik Forums
UI for WPF Forum
1 answer
448 views
Hi,

in MVVM scenario I need dynamically generate columns for RadGridView.

I created attached property for this purpose.

ItemSource is bind to property ObservableCollection<Company> Companies from VM

where Company is

    
public class Company : INotifyPropertyChanged
    {
        public Company()
        {
            Dept = new Dictionary<string, User>();
        }
 
        private Dictionary<string,User> dept;
 
        public Dictionary<string,User> Dept
        {
            get { return dept; }
 
            set
            {
                dept = value;
                OnPropertyChanged("Dept");
            }
        }
    }

and User is

    
public class User : INotifyPropertyChanged
    {
 
        private string firstName;
 
        public string FirstName
        {
            get { return firstName; }
 
            set
            {
                firstName = value;
                OnPropertyChanged("FirstName");
            }
        }
 
        private string lastName;
 
        public string LastName
        {
            get { return lastName; }
 
            set
            {
                lastName = value;
                OnPropertyChanged("LastName");
            }
        }
    }


I generate columns in VM in this way.

In VM I have property ObservableCollection<ColumnDefinition> which is bind to attached property in View.

ColumnDefinition is abstraction for GridViewDataColumn.

<telerik:RadGridView ItemsSource="{Binding Path=Country.Companies, UpdateSourceTrigger=PropertyChanged}"
                     dynamicCol:RadGridViewColumnsBinding.ColumnsCollection="{Binding Path=Columns}">
    <telerik:RadGridView.Resources>
        <DataTemplate x:Key="UserTemplate"
                      DataType="{x:Type models:User}">
            <StackPanel>
                <TextBlock Text="LastName:" />
                <TextBlock Text="{Binding Path=LastName}" />
            </StackPanel>
        </DataTemplate>
    </telerik:RadGridView.Resources>
</telerik:RadGridView>


When I need add column to RadGridView I add ColumnDefinition obj to property Columns.

I need apply DataTemplate on GridViewDataColumn and this is which not work for me.

Exactly binding to property User.LastName in DataTemplate not work.

I use this binding exp for GridViewDataColumn 

                      
string bindingExp = string.Format("Dept[{0}]", columnName);
//string bindingExp = string.Format("Dept[{0}].LastName", columnName); // whithout datatemplate this work
 
                      var binding = new Binding(bindingExp)
                      {
                          UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
 
                      };
 
                      Columns.Add(new ColumnDefinition
                      {
                          Header = columnName,
                          DataMemberBinding = binding,
                          Tag = ColumnTag,
                          UniqueName = Guid.NewGuid().ToString(),
                          CellTemplateName = "UserTemplate",
                      });




I try attached several times sample project but always get error:

The selected file(s) cannot be attached because it may exceed the maximum attachment size (2 MB) or is from not allowed type (allowed: .gif, .jpg, .jpeg, .png).

Attached file size is 74 KB.

Hence I uploded sample project to onedrive.

You can download here.
Dimitrina
Telerik team
 answered on 17 Nov 2014
3 answers
150 views
Hi, I would like to enquire on a solution to the problem as per title. I am dragging between 2 RadListBox. Below is an example of the desired effect I would like to achieve:

A drag drop event

Dragged 'Equipment' objects (with ID and Quantity properties):
ID: 2, Quantity: 2
ID: 5, Quantity: 3
ID: 9, Quantity: 1

Destination Objects ('Equipment' objects already in destination RadListBox):
ID: 1, Quantity: 3
ID: 2, Quantity: 3
ID: 9, Quantity: 2


Desired outcome in destination RadListBox after drag drop event:
ID: 1, Quantity: 3
ID: 2, Quantity: 5 (3+2)
ID: 5, Quantity: 3
ID: 9, Quantity: 3 (2+1)

Instead of:
ID: 1, Quantity: 3
ID: 2, Quantity: 3
ID: 9, Quantity: 2
ID: 2, Quantity: 2
ID: 5, Quantity: 3
ID: 9, Quantity: 1


Thanks a lot for your attention. Please let me know if further details is needed.
​





Kalin
Telerik team
 answered on 17 Nov 2014
12 answers
365 views
Hi support,

I want my Schedule View to look like  this. Please let me know how I can change a new Schedule to look exactly like this.

Please guide me or send me some code snippet or zip files. this is very critical because we are dedcing to use Schedule View or not.

Thanks for the help,
Vivek.
Yana
Telerik team
 answered on 17 Nov 2014
8 answers
185 views
Hello,

I'am using RadTileView as a Dashboard that will show status of 8 different stations. These stations follow a workflow and can be in different states. Each state has a specific Large View. The Small and Normal will all look similar. Also, as a station changes from StateX to StateY, I receive that info through an EventHandler and want to change thus the XAML + its associated ViewModel in its corresponding Large tile.

I think through the DataTemplate (see below) it is doable. However, from the codebehind, how do I :
1- Empty Large Content for the corresponding Tile,
2- Set it with a different XAML (currently existing as UserControl) and set its datacontext to its specific ViewModel.

<DataTemplate x:Key="ContentTemplate" >
                <telerik:RadFluidContentControl ContentChangeMode="Manual" Name="radFluidContentControl"
                        State="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadTileViewItem}, Path=TileState, Converter={StaticResource fluidContentStateConverter}}">
                    <telerik:RadFluidContentControl.SmallContent>
                        <local:SmallContent x:Name="smallContent"/>
                    </telerik:RadFluidContentControl.SmallContent>
                    <telerik:RadFluidContentControl.Content>
                        <local:Content x:Name="normalContent" />
                    </telerik:RadFluidContentControl.Content>
                    <telerik:RadFluidContentControl.LargeContent>
                        <!-- ***************** -->
                        <!-- The XAML + its VM would vary for each items in tile view. How do I set these individually for each Tile????-->
                        <!-- ***************** -->
                        <local:LargeContentConfig x:Name="largeContent" />
                    </telerik:RadFluidContentControl.LargeContent>
                </telerik:RadFluidContentControl>
            </DataTemplate>

Thx
Chris

Thx
Pavel R. Pavlov
Telerik team
 answered on 17 Nov 2014
1 answer
172 views
Hi,

I have a WPF model with a table "table1" composed by "table1_column1", "table1_column2" and "table1_column3" and another table "table2" composed by "table2_column1", "table2_column2" and "table2_column3".
I have a 0..1 relation from "table1" to "table2", it means that an object from "table1" can be related with 0 or 1 "table2" object.
Now I have create a RadGridView that takes all the table1 objects as ItemsSource.
I have the following columns in the RadGridView: "table1_column1", "table1_column2", "table1_column3", "table2_column1" and everything is working fine, except for two problems: if I try to sort the grid by "table2_column1" or use a filter on "table2_column1", no entry is shown in the table, just the headers.
Sorting and filtering on "table1_column1", "table1_column2" and "table1_column3" work fine.
Here is the RadGridView code.

<telerik:RadGridView Name="dataGrid1" FrozenColumnCount="10" Margin="0,72,0,12" AllowDrop="True" AutoGenerateColumns="False" EnableColumnVirtualization="True" CanUserSortColumns="True" CanUserResizeColumns="True" CanUserReorderColumns="True" ShowGroupPanel="False" ShowColumnSortIndexes="False" MouseDoubleClick="showDetails">
 
            <telerik:RadGridView.Columns>
 
                <telerik:GridViewDataColumn x:Name="table1_column1" Header="table1_column1" DataMemberBinding="{Binding Path=table1_column1}" IsReadOnly="true"/>
                <telerik:GridViewDataColumn x:Name="table1_column2" UniqueName ="table1_column2" Header="table1_column2" DataMemberBinding="{Binding Path=table1_column2}" IsReadOnly="true" Width="100" IsAutoGenerated="False"/>
                <telerik:GridViewDataColumn x:Name="table1_column3" Header="table1_column3" DataMemberBinding="{Binding Path=table1_column3}" IsReadOnly="true"/>
                <telerik:GridViewDataColumn x:Name="table2.table2_column1" Header="table2_column1" DataMemberBinding="{Binding Path=table2_column1}" IsReadOnly="true"/>
                 
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>


Any suggestion?

Thanks.
Dimitrina
Telerik team
 answered on 17 Nov 2014
1 answer
239 views
Hello,


I have a radgridview that is pretty simple. It has 8 columns, all read-only but the last one. The grid holds thousands of records without paging (by design).

The issue I am facing is when the user scrolls to an record that would initially be below the page break and edits the record. When they exit the cell to commit the change the grid jumps back up to the top. 

How can I get the radgridview to not jump to the top of records and stay focus on the edited record and surrounding records? Is is an issue with sorting?

Thank you,
Aryn
Dimitrina
Telerik team
 answered on 17 Nov 2014
1 answer
599 views
I need to close RadWindow(s) which are children of Application.Current.MainWindow programmatically but RadWindows present as "Telerik.Windows.Controls.InternalWindow.ChromelessWindowHelper+WindowHostWindow: Window Header" so I'm unable to cast that back to RadWindow and use Close() method. Here is what I tried:

                foreach (var w in Application.Current.Windows)
                {
                    var rw = w as RadWindow;
                    if (rw == null) continue;
                    rw.Close();
                }

                foreach (var rw in Application.Current.MainWindow.ChildrenOfType<RadWindow>())
                {                    
                    rw.Close();
                }

So, how exactly do I close RadWindow(s) which are children of Application.Current.MainWindow programmatically?
Vladi
Telerik team
 answered on 17 Nov 2014
1 answer
120 views

Wondering about this - since this free version supports third party extensions now...

http://www.visualstudio.com/news/vs2013-community-vs

Nikolay
Telerik team
 answered on 17 Nov 2014
1 answer
307 views
I have a problem when I want to build/test a connection.
Error: Arithmetic operation resulted in an overflow"

 I use the newest Desegner for telerik WPF: 2014.2.2001 from 24 October 2014.
.NET v4.030319
I use SQL 2012, same .NET version.
I have Windows 8 on my computer.

Is there a solution, some ideas, a fix?
Yana
Telerik team
 answered on 17 Nov 2014
1 answer
155 views
Hello, I'm Lee

I have one question.

It's 'TileGroupContainer'.

Exception is '{clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls}TileGroupContainer find not format'

I don't know, why occur it

What should I do??
Maya
Telerik team
 answered on 17 Nov 2014
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
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
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
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?