I have a requirement where I need to pop a window up in order to show the detail of the selected tree node. I need it to pop up in a location just to the right of what I selected in the TreeListView.
I figure this could be done using the Mouse Location or the Location relative to the selected node. I haven't been able to get either to work.
My approach is to pop up a simple Tool window at that location. The better solution would be to have an EditTemplate that pops into its own window; but, I'm not sure if that is possible. I have a good EditTemplate (shown) but the user demands that the tree remain very skinny and doesn't want to move things around much because this is a Touch Pad.
I'm open to whatever approach is the easiest code to maintain. Thanks in advance for your help.
Here are my DataTemplates:
<
DataTemplate
x:Key
=
"TreeNodeTemplate"
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"auto"
/>
<
ColumnDefinition
Width
=
"auto"
/>
</
Grid.ColumnDefinitions
>
<
Image
Grid.Column
=
"0"
Source
=
"{Binding Image, Mode=TwoWay}"
ToolTip
=
"{Binding Barcode, Mode=TwoWay}"
/>
<
Image
Grid.Column
=
"0"
Height
=
"20"
Width
=
"20"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
Margin
=
"-20,0,0,0"
Source
=
"{Binding StatusImage, Mode=TwoWay}"
ToolTip
=
"{Binding StatusName, Mode=TwoWay}"
/>
<
TextBlock
Grid.Column
=
"1"
Text
=
"{Binding Name, Mode=TwoWay}"
Margin
=
"5"
ToolTip
=
"{Binding Description}"
/>
</
Grid
>
</
DataTemplate
>
<
DataTemplate
x:Key
=
"TreeNodeEditTemplate"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
Image
Source
=
"{Binding Image, Mode=TwoWay}"
VerticalAlignment
=
"Top"
/>
<
Grid
Margin
=
"5"
Background
=
"Cornsilk"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"auto"
/>
<
RowDefinition
Height
=
"auto"
/>
</
Grid.RowDefinitions
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"125"
/>
<
ColumnDefinition
Width
=
"*"
/>
</
Grid.ColumnDefinitions
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"28"
/>
<
RowDefinition
Height
=
"28"
/>
<
RowDefinition
Height
=
"28"
/>
<
RowDefinition
Height
=
"28"
/>
<
RowDefinition
Height
=
"auto"
/>
</
Grid.RowDefinitions
>
<
Label
Content
=
"ID:"
Grid.Column
=
"0"
Grid.Row
=
"0"
HorizontalAlignment
=
"Right"
VerticalAlignment
=
"Center"
/>
<
TextBlock
Grid.Column
=
"1"
VerticalAlignment
=
"Center"
Text
=
"{Binding ID, Mode=TwoWay}"
/>
<
Label
Content
=
"Name:"
Grid.Column
=
"0"
Grid.Row
=
"1"
HorizontalAlignment
=
"Right"
VerticalAlignment
=
"Center"
/>
<
TextBox
Grid.Column
=
"1"
Grid.Row
=
"1"
VerticalAlignment
=
"Center"
Text
=
"{Binding Name, Mode=TwoWay}"
IsEnabled
=
"{Binding IsEditableStatus}"
IsReadOnly
=
"{Binding IsEditableStatus, Converter={StaticResource BoolToOppositeBoolConverter}}"
/>
<
Label
Content
=
"Description:"
Grid.Column
=
"0"
Grid.Row
=
"2"
HorizontalAlignment
=
"Right"
VerticalAlignment
=
"Center"
/>
<
TextBox
Grid.Column
=
"1"
Grid.Row
=
"2"
VerticalAlignment
=
"Center"
Text
=
"{Binding Description, Mode=TwoWay}"
IsEnabled
=
"{Binding IsEditableStatus}"
IsReadOnly
=
"{Binding IsEditableStatus, Converter={StaticResource BoolToOppositeBoolConverter}}"
/>
<
Label
Content
=
"Barcode:"
Grid.Column
=
"0"
Grid.Row
=
"3"
HorizontalAlignment
=
"Right"
VerticalAlignment
=
"Center"
/>
<
TextBox
Grid.Column
=
"1"
Grid.Row
=
"3"
VerticalAlignment
=
"Center"
Text
=
"{Binding Barcode, Mode=TwoWay}"
/>
</
Grid
>
<
GroupBox
Header
=
"Status"
Grid.Row
=
"4"
Margin
=
"5"
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"125"
/>
<
ColumnDefinition
Width
=
"*"
/>
</
Grid.ColumnDefinitions
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"28"
/>
<
RowDefinition
Height
=
"28"
/>
</
Grid.RowDefinitions
>
<
Label
Content
=
"CRUD Status:"
Grid.Column
=
"0"
Grid.Row
=
"0"
HorizontalAlignment
=
"Right"
VerticalAlignment
=
"Center"
/>
<
TextBlock
Grid.Column
=
"1"
Grid.Row
=
"0"
VerticalAlignment
=
"Center"
Text
=
"{Binding StatusName, Mode=TwoWay}"
/>
<
Label
Content
=
"Inspect Status:"
Grid.Column
=
"0"
Grid.Row
=
"1"
HorizontalAlignment
=
"Right"
VerticalAlignment
=
"Center"
/>
<
TextBlock
Grid.Column
=
"1"
Grid.Row
=
"1"
Text
=
"{Binding InspectStatusName, Mode=TwoWay}"
VerticalAlignment
=
"Center"
/>
</
Grid
>
</
GroupBox
>
</
Grid
>
</
StackPanel
>
</
DataTemplate
>
Hi,
there is already a Question "Show validation after insert exception" but no fully answers :( for me.
So i had this problem.
Project ( is in MVVM with DataAccess ) and RadDataGrid
In case i add a new Record i catch the Event "RowEditEnded" to a Command with <telerik:EventBinding> in XAML and the
EventOperationType = GridViewEditOperationType.Insert is found.
Then i Save the Data to DB with DataAccess context.SaveChanges() ; and DB is sending Back a Exception DuplicateKeyException
so Commit was not done. But Record was added to the Grid. Now i try to change the Attribute (PK) which raised the violation to a valid one and try the same again. The Event is raised "RowEditEnded" as wanted but now not in "Insert" Mode has switched from "GridViewEditOperationType.Insert" (as it was before on the Record) to "GridViewEditOperationType.Edit" which is different in operation then the Insert a new Record in DB.
So Question is how could i tell the Grid not to do this automatic switch until commit is valid (without exception ) done.
The Record should stay in Insert Mode until Storing was valid.
Or if there is a better solution to handling exceptions on DB side please let me know.
thnx br thomas
Hello,
I want to override some functionality of the GridView combobox, datepicker and data column.
I overriden the class GridViewComboBoxColumn, but the functionality is not working.
My goal is for the combobox, when it receives focus it should show the dropdown, the user can then select the value with one enter and control should automatically move to the next field in the GridView.
The same functionality I want to implement for the DatePicker. And for the Textbox I want the enter function like the tab.
public
class
CustomGridViewComboBoxColumn : GridViewComboBoxColumn
{
#region Fields
private
bool
_isEnterInThisCombo =
false
;
#endregion
#region Constructor
#endregion
#region Methods
private
void
ComboBox_PreviewKeyUp(
object
sender, KeyEventArgs e)
{
if
(e.Key == Key.Enter && _isEnterInThisCombo)
{
if
(
this
.IsVmEditMode && ! Validation.GetHasError(
this
))
{
CbIsCheckedForAudit =
true
;
}
this
.MoveFocus(
new
TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next));
/* Reset flag */
_isEnterInThisCombo =
false
;
}
}
private
void
ComboBox_PreviewKeyDown(
object
sender, KeyEventArgs e)
{
if
(e.Key == Key.Enter)
{
_isEnterInThisCombo =
true
;
}
}
private
void
ComboBox_Loaded(
object
sender, RoutedEventArgs e)
{
if
(
this
.IsVmEditMode)
// && this.SelectedValue == null)
this
.CbOpenDropDownOnFocus =
true
;
else
if
(
this
.IsVmEditMode)
this
.CbOpenDropDownOnFocus =
false
;
else
this
.CbOpenDropDownOnFocus =
true
;
}
#endregion
#region Dependency Properties
public
bool
CbOpenDropDownOnFocus
{
get
{
return
(
bool
)GetValue(CbOpenDropDownOnFocusProperty); }
set
{ SetValue(CbOpenDropDownOnFocusProperty, value);}
}
public
static
readonly
DependencyProperty CbOpenDropDownOnFocusProperty =
DependencyProperty.Register(
"CbOpenDropDownOnFocus"
,
typeof
(
bool
),
typeof
(CustomGridViewComboBoxColumn),
new
PropertyMetadata(
false
));
public
bool
CbIsCheckedForAudit
{
get
{
return
(
bool
)GetValue(CbIsCheckedForAuditProperty); }
set
{ SetValue(CbIsCheckedForAuditProperty, value); }
}
public
static
readonly
DependencyProperty CbIsCheckedForAuditProperty =
DependencyProperty.Register(
"CbIsCheckedForAudit"
,
typeof
(
bool
),
typeof
(CustomGridViewComboBoxColumn),
new
PropertyMetadata(
false
));
public
virtual
bool
IsVmEditMode
{
get
{
return
(
bool
)GetValue(IsVmEditModeProperty); }
set
{ SetValue(IsVmEditModeProperty, value); }
}
public
static
readonly
DependencyProperty IsVmEditModeProperty =
DependencyProperty.Register(
"IsVmEditMode"
,
typeof
(
bool
),
typeof
(CustomGridViewComboBoxColumn),
new
PropertyMetadata(
false
));
#endregion
Thanks in advance.
Marcel
<
telerik:RadGridView
x:Name
=
"testRadGridView"
ItemsSource
=
"{Binding ItemList}"
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=MainItemA}"
Header
=
"Main Item A "
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=MainItemB}"
Header
=
"Main Item B "
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=SubItem.SubItemA}"
Header
=
"Sub Item A"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=SubItem.SubItemB, Converter={StaticResource MyTestConverter}}"
Header
=
"Sub Item B"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
public
class
Item
{
public
string
MainItemA {
get
;
set
; }
public
int
MainItemB {
get
;
set
; }
public
SubItem SubItem {
get
;
set
; }
}
public
class
SubItem
{
public
string
SubItemA {
get
;
set
; }
public
DateTime SubItemB {
get
;
set
; }
}
public
class
TestConverter : IValueConverter
{
public
object
Convert(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
DateTime dateTimeValue = (DateTime)value;
return
dateTimeValue.ToString(
"yyyy-MM-dd HH:mm:ss"
);
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
throw
new
NotSupportedException();
}
}
public
class
MainWindowViewModel
{
public
ObservableCollection<Item> ItemList {
get
;
set
; }
public
MainWindowViewModel()
{
ItemList =
new
ObservableCollection<Item>();
ItemList.Add(
new
Item { MainItemA =
"Main Item A1"
, MainItemB = 1, SubItem =
new
SubItem { SubItemA =
"Sub Item A1"
, SubItemB =
new
DateTime(2014,1,1,13,12,11) } });
ItemList.Add(
new
Item { MainItemA =
"Main Item A2"
, MainItemB = 2, SubItem =
new
SubItem { SubItemA =
"Sub Item A2"
, SubItemB =
new
DateTime(1999, 4, 3, 2, 1, 0) } });
}
}
So I'm trying to customize the RadMaskedTextInput to where the errors line up.
Right now they popup right next to the textbox associated with them.
I was thinking this could be possible by putting the textboxes in a fixed width grid and setting the horizontal alignment to left.
I have attached the current way it looks and the way I want it to look like.
Any help would be appreciated.
Hello,
I am
working on a custom datagrid for my application and I want to have a custom
column where the cell has a Textbox and a small button. When the user clicks the
button a small screen must be shown where the user can enter some values. The
total of the inputting values need to be displayed back in the gridview.
I am
looking at implementing this, but have a hard time doing. I like to have the
same style for the button and the subscreen as the datepicker/Calculatorpicker.
The content
of the dropdown screen need to be replacable by other content using a usercontrol.
Whats the
best way to implement this, should I create a custom control for this? And then
create a custom column according to the approach below?
Or is there a better way to implement this?
http://docs.telerik.com/devtools/wpf/controls/radgridview/columns/how-to/create-date-time-picker-column.html
Thank in
advance.
Marcel
I have used the wizard events to control my wizard navigation but once I cancel the navigation for one step using e.Cancel, The SelectionChanging/ SelectionChanged events doesn't get fired.
I was using the UI for WPF Q1 2015 and now updated to UI for WPF Q2 2015 but still the same problem exists.
check this code sample
using System.Windows;
using Telerik.Windows.Data;
using Telerik.Windows.Controls;
namespace WizardNavigation
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private ObservableItemCollection<WizardPage> collection;
private int cancelCounter = 1;
public MainWindow()
{
InitializeComponent();
collection = new ObservableItemCollection<WizardPage>();
var firstPage = new WizardPage {Content = "My First Page Content"};
var secondPage = new WizardPage {Content = "My Second Page Content"};
var thirdPage = new WizardPage {Content = "My Third Page Content"};
var fourthPage = new WizardPage {Content = "My Fourth Page Content"};
myWizard.WizardPages.Add(firstPage);
myWizard.WizardPages.Add(secondPage);
myWizard.WizardPages.Add(thirdPage);
myWizard.WizardPages.Add(fourthPage);
myWizard.Next += myWizard_Next;
myWizard.SelectionChanging += myWizard_SelectionChanging;
}
void myWizard_SelectionChanging(object sender, SelectedPageChangingEventArgs e)
{
if (cancelCounter != 2) return;
e.Cancel = true;
MessageBox.Show("Cancelled, Click again to navigate");
}
void myWizard_Next(object sender, NavigationButtonsEventArgs e)
{
// You will need to click the next twice for to move to step 3.
// SelectionChanging will not be called on the second click
//SelectionChanging will be called when moving to forth step.
cancelCounter++;
var wizard = sender as RadWizard;
if (wizard.SelectedPage.Content == "My First Page Content")
{
e.SelectedPageIndex = 2;
}
}
}
}
​