Hi there,
I'd like to know if you can use an ivalueconverter in a textcolumn, or if not, how you can use the filter menu of a textcolumn in a templatecolumn?
On a related note; can you also use a converter on the grouping header?
Bit of background, for further clarity:
I'm trying to create a program that displays a list of files, their names and things like their last edited dates.
As such my datasource is a list(fileinfo).
To display the filenames in a user friendly manner I'd like to trim the directorynames a bit.
I know how to do this using a templatecolumn, but then I lose the nice filtering menu that's built into the textcolumn.
<telerikGrid:RadDataGrid x:Name="DataGrid" SelectionUnit="Row">
<telerikGrid:RadDataGrid.Resources>
<Style TargetType="gridPrimitives:SelectionRegionBackgroundControl">
<Setter Property="Background" Value="Red"/>
<Setter Property="BorderBrush" Value="Green"/>
<Setter Property="BorderThickness" Value="2"/>
</Style>
</telerikGrid:RadDataGrid.Resources>
</telerikGrid:RadDataGrid>
this.DataGrid.ItemsSource = new List<Data>
{
new Data { Country = "India", Capital = "New Delhi"},
new Data { Country = "South Africa", Capital = "Cape Town"},
new Data { Country = "Nigeria", Capital = "Abuja" },
new Data { Country = "Singapore", Capital = "Singapore" }
};
public class Data
{
public string Country { get; set; }
public string Capital { get; set; }
}
When I select one row, the SelectionRegionBorder Control doesn't work.
Hello,
In my datagrid, I use a custom DataTemplate for one of my (autogenerated) columns:
01.
Public
Class
CustomGenerateColumnCommand
02.
Implements
ICommand
03.
04.
Public
Event
CanExecuteChanged
As
EventHandler
Implements
ICommand.CanExecuteChanged
05.
06.
Public
Sub
Execute(parameter
As
Object
)
Implements
ICommand.Execute
07.
Dim
context
As
GenerateColumnContext =
CType
(parameter, GenerateColumnContext)
08.
If
context.PropertyName =
"myColumnName"
Then
09.
Dim
c
As
New
DataGridTemplateColumn
10.
c.CellContentTemplate =
CType
(XamlReader.Load(
""
&
11.
"<DataTemplate xmlns="
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
" xmlns:x="
"http://schemas.microsoft.com/winfx/2006/xaml"
" xmlns:common="
"using:MyNS.Converters"
">"
&
12.
"<Grid Background="
"{Binding StatusColor}"
">"
&
13.
"<Grid.ColumnDefinitions>"
&
14.
"<ColumnDefinition Width="
"70"
"/>"
&
15.
"<ColumnDefinition Width="
"220"
" /> "
&
16.
"</Grid.ColumnDefinitions>"
&
17.
"<TextBlock Text="
"{Binding Title}"
" Style="
"{StaticResource SubtitleTextBlockStyle}"
" TextTrimming="
"CharacterEllipsis"
" Height="
"20"
" FontSize="
"16"
"/>"
&
18.
"</Grid>"
&
19.
"</DataTemplate>"
), DataTemplate)
20.
c.Name =
"myColumnName"
21.
context.Result = c
22.
End
If
23.
End
Sub
24.
25.
Public
Function
CanExecute(parameter
As
Object
)
As
Boolean
Implements
ICommand.CanExecute
26.
'exclude those properties
27.
Dim
context
As
GenerateColumnContext =
CType
(parameter, GenerateColumnContext)
28.
Return
context.PropertyName <>
"StatusColor"
And
context.PropertyName <>
"Title"
29.
End
Function
The above works perfectly. Both properties StatusColor and Title are used in one custom formatted cell.
My questions:
For example like this:
<Grid Background=
"{Binding StatusColor, Converter={StaticResource myColorConverter}}"
>
Having myColorConverter well defined and accessible in myNS.Converters. I have tried to add the static resource in the DataTemplate, or in the grid resources or even in the top page xaml resources, but each time I get "resource could not be found".
How can I use a Binding Converter in this situation ?
For example like this:
<TextBlock Text=
"{Binding Title}"
Tapped=
"myTxt_Tapped"
x:Name=
"myTxt"
/>
My code behind would of course contain an event handler like this:
Private
Sub
myTxt_Tapped(sender
As
Object
, e
As
TappedRoutedEventArgs)
'navigate to nextPage
End
Sub
But that never gets fired. And I would expect it to fail anyway because my grid has multiple rows and thus I get multiple times the same TextBlock name ; meaning I need to attach an event handler, but how, and at which moment in the page lifecycle ?
I have also tried to use the CellTap DataGridCommand, but when I use
Public
Overrides
Sub
Execute(parameter
As
Object
)
Dim
context =
CType
(parameter, DataGridCellInfo)
If
context.Column.Name =
"myColumnName"
Then
Dim
dob
As
myObject=
CType
(context.Item.myColumnName, myObject)
CType
(Window.Current.Content, Frame).Navigate(
GetType
(nextPage), dob)
End
If
End
Sub
the last line throws a Memory Violation Exception.
How can I register an event ? How can I navigate to a new frame ?
Thanks for any help
Julien
Hello
I just do not get any further. I have two questions.
1. I have the problem that I want to set after the call of "BeginEdit ()" the focus on the first texbox?.
2. How can I jump to the next textbox with Enter like the TAB key?
Thank you
I hope my english is sufficient
Hi there,
is it possible to avoid horizontal scroll bars and let the RadDataGrid use the available space only?
Thanks, Alexander
I have a column in a table that contains an integer which is related to the primary key integer in another collection. In the column instead of displaying the integer, I am trying to display the Name field from the related collection in the grid column. Right now it displays the integer instead of the expected value from DisplayMemberPath. (The combobox is working as expected when in edit mode.) There are no errors in XAML designer, build process or in debug immediate window. I have tried a number of tweaks and all the docs I can find but nothing has worked. Seems strange combo is working exactly as expected during edit mode but DisplayMemberPath won't show in grid view mode.
<
Page.Resources
>
<
CollectionViewSource
x:Key
=
"cOwners"
Source
=
"{x:Bind Owners}"
/>
</
Page.Resources
>
<
tg:RadDataGrid
x:Name
=
"LocationsGrid"
UserEditMode
=
"Inline"
ColumnDataOperationsMode
=
"Flyout"
ItemsSource
=
"{x:Bind Locations}"
AutoGenerateColumns
=
"False"
IsTapEnabled
=
"True"
IsDoubleTapEnabled
=
"True"
SelectionMode
=
"Single"
SelectionUnit
=
"Row"
>
<
tg:RadDataGrid.Columns
>
<
tg:DataGridNumericalColumn
PropertyName
=
"Identifier"
/>
<
tg:DataGridComboBoxColumn
PropertyName
=
"OwnerId"
<!--integer in locations collection. -->
ItemsSource="{Binding Source={StaticResource cOwners}}"
SelectedValuePath="Identifier"
<!--related integer in cOwners collection-->
DisplayMemberPath="Name" />
<!--desired column display string from cOwners-->
<
tg:DataGridTextColumn
PropertyName
=
"Name"
/>
<
tg:DataGridTextColumn
PropertyName
=
"Address"
/>
<
tg:DataGridTextColumn
PropertyName
=
"City"
/>
<
tg:DataGridTextColumn
PropertyName
=
"State"
/>
<
tg:DataGridTextColumn
PropertyName
=
"PostalCode"
/>
<
tg:DataGridNumericalColumn
PropertyName
=
"Latitude"
/>
<
tg:DataGridNumericalColumn
PropertyName
=
"Longitude"
/>
<
tg:DataGridTextColumn
PropertyName
=
"Description"
/>
<
tg:DataGridTextColumn
PropertyName
=
"Image"
/>
<
tg:DataGridBooleanColumn
PropertyName
=
"Active"
/>
<
tg:DataGridDateColumn
PropertyName
=
"Modified"
/>
</
tg:RadDataGrid.Columns
>
</
tg:RadDataGrid
>
I have a Data grid that looks like so:
<
grid:RadDataGrid
Grid.Row
=
"1"
ItemsSource
=
"{Binding Notes}"
AutoGenerateColumns
=
"False"
UserEditMode
=
"None"
UserFilterMode
=
"Disabled"
UserGroupMode
=
"Disabled"
SelectionMode
=
"None"
>
<
grid:RadDataGrid.Columns
>
<
grid:DataGridDateColumn
Header
=
"Time"
PropertyName
=
"Time"
CellContentFormat
=
"{}{0:g}"
SizeMode
=
"Auto"
SortDirection
=
"Descending"
/>
<
grid:DataGridTextColumn
Header
=
"Note"
PropertyName
=
"Message"
SizeMode
=
"Stretch"
/>
</
grid:RadDataGrid.Columns
>
</
grid:RadDataGrid
>
The Time column shows the correct sort direction indicator but when the data changes (Notes is an ObservableCollection) it is not sorted automatically. Do I have to pre-sort the data I added to Notes? This seems a bit redundant.
I want to change Accent Color of RadDataGrid which is blue, on changing SystemAccentColor datagrid's accent color is not changing.
How to Change that color mentioned in ScreenShot, wherever blue color is used throughout all the DataGrid's operations.
Thank you.
Hello,
There is a RadDataGrid with couple of DataGridTemplateColumns. One of the column contains a MediaPlayerElement as a video preview.
The realized problem is when I am changing any column's size, the grid and all of the contained element's bindings are automatically read again. It causes a couple of error (and ugly behavior) on the MediaPlayerElement, the rest of the columns are working fine.
The Grid:
<telerikGrid:RadDataGrid x:Name="GridVideoFiles" Grid.Row="1" UserEditMode="External" AutoGenerateColumns="false" UserFilterMode="Disabled" UserGroupMode="Disabled"
ColumnResizeHandleDisplayMode="Always"
DragOver="UIElement_OnDragOver" AllowDrop="True"
Drop="UIElement_OnDrop"
ItemsSource="{Binding VisionFiles}">
The given column:
<telerikGrid:DataGridTemplateColumn Header="Video Player" SizeMode="Fixed" Width="300" CanUserResize="False">
<telerikGrid:DataGridTemplateColumn.CellContentTemplate>
<DataTemplate>
<Grid Width="300">
<MediaPlayerElement Width="300" Source="{Binding Media, Mode=OneTime}" AreTransportControlsEnabled="True">
<MediaPlayerElement.TransportControls>
<MediaTransportControls IsCompact="True"/>
</MediaPlayerElement.TransportControls>
</MediaPlayerElement>
</Grid>
</DataTemplate>
</telerikGrid:DataGridTemplateColumn.CellContentTemplate>
</telerikGrid:DataGridTemplateColumn>
Can you tell me any solution to prevent the binded Media property updating automatically?