I want to sort my items via a custom sort order, similar to the implementation detailed here: http://docs.telerik.com/devtools/wpf/controls/radgridview/sorting/custom#custom-sorting-handling-sorting-event
However when I do it seems that e.OldSortingState is always equal to SortingState.None and so I don't get the functionality where first click on column = Ascending, second = Descending, and third = reset to default sorting (ie. None).
The example below should mostly set the sorting to the way it would be if I didn't handle the Sorting event myself. It's only for demonstration. My issue is that I can't ever get to the "else if" and "else" blocks.
private
void
MainDataGridOnSorting(
object
sender, GridViewSortingEventArgs e)
{
RadGridView radGridView = e.Source
as
RadGridView;
if
(radGridView ==
null
)
{
e.Cancel =
true
;
return
;
}
DataView dataView = radGridView.DataContext
as
DataView;
if
(dataView ==
null
)
{
e.Cancel =
true
;
return
;
}
IEnumerable<DataRowView> dataRows = dataView.Cast<DataRowView>();
//If the sorting state is none, sort the items ascending.
if
(e.OldSortingState == SortingState.None)
{
e.NewSortingState = SortingState.Ascending;
e.Column.SortingState = SortingState.Ascending;
dataRows =
dataRows
.OrderBy(row => row.Field<
string
>(e.Column.UniqueName));
}
//If the sorting state is none, sort the items descending.
else
if
(e.OldSortingState == SortingState.Ascending)
{
// Cannot reach this block
e.NewSortingState = SortingState.Descending;
e.Column.SortingState = SortingState.Descending;
dataRows =
dataRows.OrderByDescending(row => row.Field<
string
>(e.Column.UniqueName));
}
//If the sorting state is descending, apply default sorting to the items.
else
{
// Cannot reach this block
e.NewSortingState = SortingState.None;
e.Column.SortingState = SortingState.None;
dataRows =
dataRows.OrderBy(row => row.Field<
int
>(
"PrimaryRow"
));
}
radGridView.ItemsSource = dataRows;
e.Handled =
true
;
e.Cancel =
true
;
}
Hello,
I'm using a RadDiagram where the users can add images and draw arrows.
By default, when the user draws an arrow over a shape, the arrow connects to the closest connection point. I need to modify this behavior. When the ActiveTool is ConnectorTool and the user clicks on the image, the arrow must start from the point where the user clicked, and not from the closest connection point.
In order to achieve this, I removed all connection points from the image when I add it. This didn't work as expected.
The following code sample allows me te reproduce the error. When I click outside the image, the behavior is nominal.
When I click on the image, an exception is thrown. Instead, I want the application to behave as if the image wasn't there.
In my sample, the ActiveTool is always ConnectorTool, but in my real application, the ActiveTool can have other values. This behavior must only apply to the ConnectorTool. For example, when the PointerTool is active, the user must be able to select and move the image.
class
Program
{
[STAThread]
static
void
Main(
string
[] args)
{
TestWindow win =
new
TestWindow();
win.ShowDialog();
}
}
class
TestWindow : Window
{
public
TestWindow()
{
Grid main_grid =
new
Grid();
main_grid.ColumnDefinitions.Add(
new
ColumnDefinition() { Width = GridLength.Auto });
main_grid.ColumnDefinitions.Add(
new
ColumnDefinition() { Width =
new
GridLength(1, GridUnitType.Star) });
RadDiagram my_diagram =
new
RadDiagram();
my_diagram.ActiveTool = Telerik.Windows.Diagrams.Core.MouseTool.ConnectorTool;
Grid.SetColumn(my_diagram, 1);
ViewModel vm =
new
ViewModel(my_diagram);
Button button_add_image =
new
Button();
button_add_image.Content =
"Add image"
;
button_add_image.Command = vm.CommandAddImage;
AddChild(main_grid);
main_grid.Children.Add(my_diagram);
main_grid.Children.Add(button_add_image);
DataContext = vm;
}
}
class
ViewModel : ViewModelBase
{
public
ViewModel(RadDiagram diagram)
{
MyDiagram = diagram;
}
public
RadDiagram MyDiagram {
get
;
set
; }
public
ICommand CommandAddImage {
get
{
return
new
ICommandImpl(AddImage); } }
public
void
AddImage()
{
Microsoft.Win32.OpenFileDialog open_file_dialog =
new
Microsoft.Win32.OpenFileDialog();
open_file_dialog.Filter =
"Image Files (*.png, *.jpg, *.bmp)|*.png;*.jpg;*.bmp"
;
open_file_dialog.CheckFileExists =
true
;
if
(!open_file_dialog.ShowDialog().GetValueOrDefault() || !System.IO.File.Exists(open_file_dialog.FileName))
{
return
; }
System.Windows.Media.Imaging.BitmapImage image_source =
new
System.Windows.Media.Imaging.BitmapImage(
new
Uri(open_file_dialog.FileName));
System.Windows.Controls.Image image_displayed =
new
System.Windows.Controls.Image();
image_displayed.Source = image_source;
Viewbox viewbox_added_to_diagram =
new
Viewbox();
viewbox_added_to_diagram.Stretch = Stretch.Fill;
viewbox_added_to_diagram.Margin =
new
System.Windows.Thickness(-4);
viewbox_added_to_diagram.Child = image_displayed;
RadDiagramShape shape_added_to_diagram =
new
RadDiagramShape();
shape_added_to_diagram.Content = viewbox_added_to_diagram;
shape_added_to_diagram.Background = Brushes.Transparent;
shape_added_to_diagram.BorderBrush = Brushes.Green;
shape_added_to_diagram.Connectors.Clear();
MyDiagram.AddShape(shape_added_to_diagram,
new
Point(20, 20));
}
private
class
ICommandImpl : ICommand
{
private
Action Command;
public
ICommandImpl(Action p_action) { Command = p_action; }
public
void
Execute(
object
parameter) { Command(); }
public
bool
CanExecute(
object
parameter) {
return
true
; }
public
event
EventHandler CanExecuteChanged;
}
}
I followed the instructions in another post, but I didn't manage to make it work.
I used added the following tool, but the behavior is not what I need. Now, when I click on a shape, nothing happens. I want a new connection to start when I click on a shape.
class CustomConnectionTool : ConnectionTool
{
public override bool MouseDown(PointerArgs e)
{
if (!this.IsActive) return false;
var hitItem = this.HitTestService.ItemUnderMouse as IShape;
if (hitItem == null || hitItem.Connectors.Count > 0)
return base.MouseDown(e);
else
return false;
}
}
The post suggested creating a new service or a custom tool, but I couldn't figure it out. In addition, my real application has more styles and custom behavior associated with Connections, so I'd rather not use a different class.
How else can I achieve what I need ? When the user clicks a shape, it must not start from the closest connection, but must instead start from the point where the user clicked.
Hi,
How can clear the "FieldFilter" value?
I have set FilteringMode="FilterRow" on my grid.
Until now I tried:
foreach (var column in gridWithFilters.Columns)
{
column.ClearFilters();
column.ColumnFilterDescriptor.Clear();
column.ColumnFilterDescriptor.FieldFilter.Clear();
}
but this clear the filter, but not its value!
I have also tried:
foreach (var column in gridWithFilters.Columns)
{
IColumnFilterDescriptor countryFilter = column.ColumnFilterDescriptor;
countryFilter.SuspendNotifications();
column.ColumnFilterDescriptor.FieldFilter.Filter1.Value = "";
column.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = FilterOperator.Contains;
countryFilter.ResumeNotifications();
}
but I get an error: "Input string was not in a correct format."
Is it possible to clear the "FieldFilter" value?
Thanks!
Beata
Hi,
I found how to add the zoom but I can't find a way to add the pan.
<imaging:ZoomController Grid.Row="0" ImageEditor="{Binding ElementName=ImageEditor}" Margin="0 8"/>
Thank you
Hi,
Am writing an application using Radpanelbar . My application has different operation like
PanelBar
*********************************
1) Create
a.Step1 --> View1.xaml -> screen1
b. Step2 --> View2.xaml --> screen2
c. Step3 --> View3.xaml --> screen 3
2) Modify
3) Delete
*************************************
Each operation has various stages (screens/views). When user clicks Create step1 my application should load View1.xaml.
if he clicks step2 , it should load view2.xaml and so on.
Qn
These Views/viewmodels are already created and stored in Unitycontainer. I just need to load these views when user navigates in the panelbar items.
Can someone help me with this ?
Scheduleview does not fit in available size and it display scrollbars. We want to display scheduleview without horizontal scrollbar.
Please find attached snapshot for same.
Thanks
i m starting to learn WPF right now, and i am a newbie for it.
what i am asking is i want to make simple program using radrichtextbox like outline view in MS Word, but i have no idea to make it realized,
i often read Documentation that i have from Telerik, but there is something that i dont understand about it, so would you like to guide me what step that should i do
to make simple program like this.
actually i want to know, what is document in raddocument type(exp maybe list type, or array type or json)? what can i get the value of paragraph and how to make it in tree visual..
before that, i would like to say thank you and i hope someone guide me to this.
thanks in advanced
How to set keyboard focus on Day or Week header button? See the attached screenshot.
Or I would like also implement hotkeys to set keyboard focus either of those header buttons(Day, Week or Month).