Telerik Forums
UI for WPF Forum
3 answers
97 views
I've got a RadMaskedDateTimeInput control that I use in a UserControl in my application.  My UserControl consists of the RadMaskedDateTimeInput control and two RepeatButtons:
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <telerik:RadMaskedDateTimeInput Focusable="True"
                                    Grid.Column="0"
                                    FormatString="{Binding Path=Mask, Mode=OneWay}"
                                    HorizontalAlignment="Stretch"
                                    HorizontalContentAlignment="Right"
                                    InputBehavior="Insert"
                                    IsClearButtonVisible="False"
                                    Margin="5"
                                    Mask="{Binding Path=Mask, Mode=OneWay}"
                                    Name="ValueBox"
                                    SelectionOnFocus="CaretToEnd"
                                    SpinMode="PositionAndValue"
                                    TextMode="MaskedText"
                                    UpdateValueEvent="PropertyChanged"
                                    Value="{Binding Converter={StaticResource TimeSpanConverter}, Path=Value, Mode=TwoWay,  UpdateSourceTrigger=PropertyChanged}"
                                    VerticalAlignment="Center" />
    <RepeatButton Click="IncrementButton_Click"
                  Focusable="False"
                  Grid.Column="1"
                  IsTabStop="False"
                  Name="IncrementButton">
        <Image>
            <Image.Style>
                <Style TargetType="{x:Type Image}">
                    <Setter Property="Source"
                            Value="/CustomControls;component/Resources/VolumeUpDay.png" />
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=IncrementButton, Path=IsEnabled}" Value="false" />
                                <Condition Binding="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:TimeSpanSpinner}}}" Value="DayTime" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Source" Value="/CustomControls;component/Resources/VolumeUpDisabledDay.png" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=IncrementButton, Path=IsEnabled}" Value="true" />
                                <Condition Binding="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:TimeSpanSpinner}}}" Value="NightTime" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Source" Value="/CustomControls;component/Resources/VolumeUpNight.png" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=IncrementButton, Path=IsEnabled}" Value="false" />
                                <Condition Binding="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:TimeSpanSpinner}}}" Value="NightTime" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Source" Value="/CustomControls;component/Resources/VolumeUpDisabledNight.png" />
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </Image.Style>
        </Image>
    </RepeatButton>
    <RepeatButton Click="DecrementButton_Click"
                  Focusable="False"
                  Grid.Column="2"
                  IsTabStop="False"
                  Name="DecrementButton">
        <Image>
            <Image.Style>
                <Style TargetType="{x:Type Image}">
                    <Setter Property="Source"
                            Value="/CustomControls;component/Resources/VolumeDnDay.png" />
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=DecrementButton, Path=IsEnabled}" Value="false" />
                                <Condition Binding="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:TimeSpanSpinner}}}" Value="DayTime" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Source" Value="/CustomControls;component/Resources/VolumeDnDisabledDay.png" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=DecrementButton, Path=IsEnabled}" Value="true" />
                                <Condition Binding="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:TimeSpanSpinner}}}" Value="NightTime" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Source" Value="/CustomControls;component/Resources/VolumeDnNight.png" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=DecrementButton, Path=IsEnabled}" Value="false" />
                                <Condition Binding="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:TimeSpanSpinner}}}" Value="NightTime" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Source" Value="/CustomControls;component/Resources/VolumeDnDisabledNight.png" />
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </Image.Style>
        </Image>
    </RepeatButton>
</Grid>

Here is the code that gets executed when the user clicks on either of the two RepeatButtons:
private void DecrementButton_Click( object sender, RoutedEventArgs e ) {
    ValueBox.CallSpin( false );
}
 
private void IncrementButton_Click( object sender, RoutedEventArgs e ) {
    ValueBox.CallSpin( true );
}

The Mask that I'm using for the control in this application is "HH:mm:ss.fff".  The control is used in an application that runs on a laptop with a touch screen.  It's intended for use in a police car while the officer is driving, so the controls are all big to make it easy for officers with sausage fingers to use.  One button has an arrow pointing up and the other has an arrow pointing down.  The idea is that touching either button causes the spin functionality of the RadMaskedTimeDateInput control to fire.

My problem is that if the user clicks on either button without touching on anything in the RadMaskedDateTimeInput control first, the control wants to spin the "HH" part of the DateTime value.  I'd prefer it if the control would spin the ".fff" part in this situation instead.  But there doesn't seem to be a way to programmatically specify where the input position is in the control.

How can I make this work?
Pavel R. Pavlov
Telerik team
 answered on 26 Apr 2013
1 answer
139 views
Hi,

I play around with DDManager and my desired solution is:
I have a grid - in this Grid I have several Controls - all of them have a DataContext and also an interface "you can drop on me".
Further I have a Viewmodell (DC of the grid) which knows about these Items.

My first approach (just to see how it works) resulted in a Grid where I can drag my items (I get a visual copy of them when dragging).
-- By the way - by playing around I lost this (nice) ability to drag "my item" without the need to provide a template.

Anyhow - I got stuck here.

What I need (and hopefully can approach with DragDropManager)  is:
Drag my Control within the bounds of my Grid
Showing a "Disabled" when dragged outside of my Grid (app)
Showing a "Disabled" when dragged over certain items (the container as well a the target can provide the "you can drop" information.
And last not least - when dropped I need (of course) the dragged Item and the Item where the user dropped it on.

No need for "List-Remove" or something like this - just X dropped on Y.

Is DragDropManager usable for this approach or shall I better use WPF default D&D?
The application is built on MVVM - so no code behind in the Control / Window would be nice.

Thanks
Manfred

Nick
Telerik team
 answered on 26 Apr 2013
2 answers
271 views
Hello,

I try to delete / clear the Items of a Listbox with
Me.datarowExtList.Clear()

But i get an NullReferenceException, since there are some Elements in the Listbox

I bind a ObservableCollection to the Itemsource Property of the LIstbox:
ItemsSource="{Binding datarowExtList}" SelectionMode="Single" DisplayMemberPath="DocDescription"

Private _datarowExtList As ObservableCollection(Of DataRowExt) = New ObservableCollection(Of DataRowExt)
    Public Property datarowExtList() As ObservableCollection(Of DataRowExt)
        Get
            Return _datarowExtList
        End Get
        Set(ByVal value As ObservableCollection(Of DataRowExt))
            _datarowExtList = value
            NotifyPropertyChanged("datarowExtList")
        End Set
    End Property

so - as i said, if there are no items in the Listbox shown up (ListBox.Items.Count = 0) i can do the Clear of the ObservableCollection.
But if there are any Items in the Listbox (just visual, neither in ListBox.Items or neither in my ObservableCollection) i get the NullReferenceException, on the Line of the ObservableCollection.CLear()

Whats wrong with the Listbox? what am i missing or doing wrong?

thanks for any advice

regards
Mike
Mike
Top achievements
Rank 1
 answered on 26 Apr 2013
1 answer
75 views
Hi!

I could not find any event that is fired when I add or remove items from RadTileView's itemsource. I want to be able to save user's tile positions after adding or removing tiles so is there any event that is fired when the collection changes?

Br,

Kalle
Pavel R. Pavlov
Telerik team
 answered on 26 Apr 2013
2 answers
156 views
I have a RadTreeView that is using  hierarichal data template, and it is binded with thousands of records.
I am using UI Virtualization, to increase performance and the VirtualizationMode is standard.

In my case, i want to choose a group and highlight all children recursively, however it don't highlight all the children, and i guess this is due to the virtualization, as some of the children are not yet rendered.

This is my xaml tree code:

 

<my:RadTreeView Margin="2,2,2,0" IsLineEnabled="True" Name="RadtreeView1" IsVirtualizing="True" tree:TreeViewPanel.VirtualizationMode="Hierarchical" IsLoadOnDemandEnabled="True" TabIndex="1" telerik:TextSearch.TextPath="Fields.Name" IsDragDropEnabled="False" SelectionMode="Multiple" Background="White" KeyDown="RadtreeView1_KeyDown" Selected="RadtreeView1_Selected" ScrollViewer.VerticalScrollBarVisibility="Visible">
  
  
  
<telerik:RadContextMenu.ContextMenu >
  
  
  
<telerik:RadContextMenu x:Name="RadContext" Opened="RadContextMenu_Opened" >
  
  
  
<MenuItem Header="Select All Children" Click="MenuItem_Click"/>
  
  
  
</telerik:RadContextMenu>
  
  
  
</telerik:RadContextMenu.ContextMenu>
  
<my:RadTreeView.ItemTemplate>
  
  
  
<HierarchicalDataTemplate >
  
<StackPanel Orientation="Horizontal" >
  
  
  
<Image Source="{Binding Path=Fields.ImagePath}"></Image>
  
  
  
<TextBlock Text="{Binding Path=Fields.Code}" Foreground="{Binding Path=Fields.isGroup,Converter={StaticResource BoolFontConverter} }" Width="50"></TextBlock>
  
<TextBlock Text=" | " Foreground="{Binding Path=Fields.isGroup,Converter={StaticResource BoolFontConverter} }"></TextBlock>
  
<TextBlock Text="{Binding Path=Fields.Name}" Foreground="{Binding Path=Fields.isGroup,Converter={StaticResource BoolFontConverter} }" Width="200"></TextBlock>
  
<TextBlock Text=" | " Foreground="{Binding Path=Fields.isGroup,Converter={StaticResource BoolFontConverter} }"></TextBlock>
  
<TextBlock Text="{Binding Path=Fields.Alias}" Foreground="{Binding Path=Fields.isGroup,Converter={StaticResource BoolFontConverter}}" Width="200"></TextBlock>
  
</StackPanel>
 
</HierarchicalDataTemplate>
  
</my:RadTreeView.ItemTemplate>
  
  
  
</my:RadTreeView>
This is the C# Code of recursion selection :

 

 

foreach(RadTreeViewItem item in SelectedNode.ChildrenOfType<RadTreeViewItem>())
  
{
  
item.IsSelected = true;
  
}

 


Notes:
1-This code do not select all the children.
2-SelectedNode is of type RadTreeViewItem.


Thanks in advance
Bill
Top achievements
Rank 1
 answered on 26 Apr 2013
7 answers
235 views
Hi,

I used the GridView example "Various Data Sources" as a guide in loading xml data into a Grid View. That is fill a dataset and then executes a DataSet.GetXml() to get the xml.  This works great except that all the columns are of system type string. Can you tell me how to get the correct system data types into the GridView?

Thanks
Rich
Richard Harrigan
Top achievements
Rank 1
 answered on 26 Apr 2013
1 answer
346 views
There seems to be a bug with the raddatepicker, when a bound property is updated, the value displayed is not updated to the correct value. I'm trying to prevent the user from entering a future date, and I can step through the property and field is setting it correctly, also, after the change is raised, it's returning the new date set in code behind, but the UI still displays the typed in date.  This code works as expected with the built in WPF datepicker. (ie the UI updates to the correct date (DateTime.Now) if a future date is entered).

<telerik:RadDatePicker SelectedDate="{Binding Path=ApplicationDate, Mode=TwoWay}" DisplayDateEnd="{x:Static sys:DateTime.Now}"/>


The property for the bound value is defined as
public DateTime? ApplicationDate
        {
            get { return Loan.ApplicationDt; }
            set
            {
                if (value > DateTime.Now.Date)
                    Loan.ApplicationDt = DateTime.Now.Date;
                else
                    Loan.ApplicationDt = value;
                RaisePropertyChanged("ApplicationDate");
            }
        }
Eric
Top achievements
Rank 1
 answered on 25 Apr 2013
3 answers
144 views
Hi,

How to achieve the following behavior: I need to show the concrete child (string type) from the parent container:

<telerik:PropertyDefinition Binding="{Binding Container}">
    <telerik:PropertyDefinition.NestedProperties>
        <telerik:PropertyDefinition Binding="{Binding Children[0]}"/>                          
    </telerik:RadPropertyGrid.PropertyDefinitions>
</telerik:PropertyDefinition>

It does not enter the Children collection.
I've tried to write the converter but the result - it shows combobox instead of textbox.

public class EnumerableConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {            
            var enumerable = (IEnumerable)value;
            var index = 0;
            var position = int.Parse((string) parameter);
            var enumerator = enumerable.GetEnumerator();
            while (enumerator.MoveNext())
            {
                if (index == position)
                {
                    return enumerator.Current;
                }
                index++;               
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Thanks
Maya
Telerik team
 answered on 25 Apr 2013
1 answer
102 views

Hello,

I’m using the RadGridView in my application to show a list of items. As I started to use grouping, I encountered some problems.

  1. It seems that grouping is disabled if there are invalid items in the data grid. Though I found a way to overcome this (I need the grouping feature for my application all the time, even if there is an invalid item in the grid) I wondered if there is a regular solution to enable grouping while having an invalid row in the grid.
  2. An InvalidOperationException is thrown in the CollapseAllGroups method. The exception message says “No collection”.
    Here is my scenario: I selected two grouping criteria (e.g. “User” and “Date”). So if I have only one element of a specific user in the specific date I’ll get the exception I previously described.
  3. I want to be able to jump through the cells of the selected row by pressing the tabulator key. The problem is: if I have set at least one grouping criteria, pressing the tabulator key opens the next group instead of jumping to the next cell of the currently selected row.
  4. Although I found out, that an event which gets attached to the PropertyChanged event of the selected item in the code behind no longer is executed if I group the grid. The event is still attached, but no changes on the item trigger it. So my question is: does grouping override normal code behind with own default methods?
Ivan Ivanov
Telerik team
 answered on 25 Apr 2013
3 answers
191 views
Hi,

I bind a PropertyGrid to a pretty complex object generated by Linq2SQL.
I implemented IDataErrorInfo on the object.
Further let the PropertyGrid autogenerate the properties.

Now I have two Problems - this[string ColumnName] never gets called.
Next - the property Grid tries to bind "Error" (I know I can fix this in code behind - but this would break my so far "no code behind" MVVM design) - but this isn't very important.
Last not least I implemented "IsValid" like in the following snippet.
    public static bool IsValid(this DependencyObject obj) {
            // The dependency object is valid if it has no errors, 
            //and all of its children (that are dependency objects) are error-free.
            return !Validation.GetHasError(obj) &&
                GetVisualTreeChildren(obj)
                .OfType<DependencyObject>()
                .All(child => IsValid(child));
        }
        //VisualTreeHelper don't have a method to get all the children of a visual object
        private static IEnumerable GetVisualTreeChildren(DependencyObject parent) {
            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
                yield return VisualTreeHelper.GetChild(parent, i);
        }
 
 
//OK handler in VM using the IsValid extension
    protected override bool HandleOKCanExecute(object arg) {
            if (this.TheView != null) {
                return(this.TheView.IsValid());
                }
            return (false);            
        }

I further know that I could decorate my object with attributes - but the reason to use your PropertyGrid is that the object is large (a lot of properties) and I don't want to define all these things. And it would be hard without touching the Linq2Sql autogenerated code.

Main Problem - no validation (this[string ColumnName] occurs.

Manfred
Ivan Ivanov
Telerik team
 answered on 25 Apr 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?