Telerik Forums
UI for WPF Forum
0 answers
166 views
Hello


There is a demo application to test some components of telerik. No complex code, only "play" with some properties.

From visual studio works great, including the publication did not present any problems, no warning, no errors.

So far so good ...

However, when you want to run the published application from the IE browser, it displays an error window abruptly.

Running the application from within visual studio shows aparentmente an initialization error telerik controls, something like:

System.TypeInitializationException was unhandled<br>Message: Se produjo una excepción en el inicializador de tipo de 'Telerik.Windows.Documents.UI.Extensibility.RadCompositionInitializer'.


This application in the event Page_Loaded performs an initial load of data in a RadGridView against sqlserver is performed without any problems, showing the data and then to the second application is aborted with the error described above.

How I can solve this?


In advance thank you all ....
Romell
Top achievements
Rank 1
 asked on 03 Aug 2012
5 answers
206 views
Am I aiming for the wrong thing to think I can use the RadTimePicker to select a Timepsan?

I need get rid of the AM PM and also stop it from thinking/displaying 00:00:00 as 12:00PM?

ohhh and what exactly am i binding to? SelectedTime={binding TimeSpan}?

thanks in advance

Michael
Michael
Top achievements
Rank 1
 answered on 03 Aug 2012
3 answers
130 views
Hi,

I have created new GridViewDateTimeColumn that will handle DateTime properties. In this column I have added one dependency property that will define StringFormat for DateTime values.

// Dependency Property
public static readonly DependencyProperty StringFormatProperty =
             DependencyProperty.Register("StringFormat", typeof(string),
             typeof(GridViewDateTimeColumn), new FrameworkPropertyMetadata(string.Empty, StringFormatChanged));
 
public string StringFormat
{
    get { return (string)GetValue(StringFormatProperty); }
    set { SetValue(StringFormatProperty, value); }
}
 
private static void StringFormatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    var column = (GridViewDateTimeColumn)d;
    column.DataMemberBinding.StringFormat = e.NewValue.ToString();
    column.Refresh();
}

xaml

<my_controls:GridViewDateTimeColumn DataMemberBinding="{Binding SomeDateTimeProperty, Mode=TwoWay}"
                 StringFormat="{Binding DataContext.StringFormat, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                                        >

However, since the cell/column layout is created only once, I am unable to force the Column to rebind its values. StringFormatChanged is executed, and StringFormat property for column DataMemberBinding is set correctly, but original StringFormat is still active.

How can I make this work?

Regards,
Goran
Goran
Top achievements
Rank 1
 answered on 03 Aug 2012
3 answers
120 views
Hello,

I have a TreeListView which is supposed to show a collection with different filters applied in two view states, the states are maintained by one bool property in the view model.

The value converter works correctly in that I can see the values being passed and returned, and in one of the states all items in the collection are shown correctly in the view. When switching back to the previous state, and the second collection view is bound, only a few of the rows are shown, even though this second collection contains the required number rows.

<telerik:RadTreeListView.ItemsSource><br>               
<
MultiBinding Converter="{StaticResource IsExpandedToCollectionViewConverter}">
                    <Binding Path="IsExpanded"/>
                    <Binding Path="DataContext" RelativeSource="{RelativeSource AncestorType=Grid}"/>
        </MultiBinding>
</telerik:RadTreeListView.ItemsSource>


The above code shows how the ItemsSource is bound, the IsExpanded property maintains the state is a boolean, and DataContext is the viewModel with the two collection view properties.

The two collectionview sources are SummaryView and SortedView. When the control is first loaded, the summary view is shown, when expanded the SortedView is shown. 

Additionally, if the SummaryView is empty, then the Visibility of the treelistview is set to collapsed. In the expanded view the treelistview, the visibility however works fine.

Thank You

Hasanain



Vera
Telerik team
 answered on 03 Aug 2012
1 answer
133 views
Hello,

In the scenario that we have, we need to drag items from a TreeView onto an image.  The image is a map and has a couple of collections items added to display on top of the map.  I am using the RadDragAndDropManager to drop items onto the map.

Here is the XAML for defining the target:

....
<Grid x:Name="mapGrid"
                  Visibility="{Binding Text, ElementName=mapFilenameTextBox, Converter={StaticResource StringEmptyToVisibilityConverter}}"
                  HorizontalAlignment="Center" VerticalAlignment="Center"
                  Margin="2">
                <Image x:Name="mapImage"
                       Source="{Binding MapFilename, Mode=OneWay}"
                       Stretch="Uniform" StretchDirection="Both" SizeChanged="mapImage_SizeChanged" Loaded="mapImage_Loaded"/>


                <ItemsControl x:Name="mapSymbolLabelsItemsControl"
                              ItemsSource="{Binding MapSymbolLabels}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas>
                                <Canvas.Background>
                                    <SolidColorBrush Opacity="0"/>
                                </Canvas.Background>
                            </Canvas>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemContainerStyle>
                        <Style>
                            <Setter Property="Canvas.Top" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Top}" />
                            <Setter Property="Canvas.Left" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Left}" />
                            <Setter Property="Label.ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=LabelName}" />
                        </Style>
                    </ItemsControl.ItemContainerStyle>
                </ItemsControl>


                <ItemsControl x:Name="mapAreaItemsControl"
                              AllowDrop="True"
                              Drop="mapAreaItemsControl_Drop"
                              MouseLeftButtonDown="mapAreaItemsControl_MouseButtonDown"
                              MouseRightButtonDown="mapAreaItemsControl_MouseButtonDown"
                              MouseMove="mapAreaItemsControl_MouseMove"
                              GiveFeedback="mapAreaItemsControl_GiveFeedback"
                              ItemsSource="{Binding MapSymbols}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas x:Name="mapCanvas">
                                <Canvas.Background>
                                    <SolidColorBrush Opacity="0"/>
                                </Canvas.Background>
                            </Canvas>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemContainerStyle>
                        <Style>
                            <Setter Property="Canvas.Top" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Top}" />
                            <Setter Property="Canvas.Left" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Left}" />
                            <Setter Property="Image.ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=SymbolName}" />
                        </Style>
                    </ItemsControl.ItemContainerStyle>
                    <ItemsControl.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="{l:Translate DeleteContextMenuItem}" Command="{Binding DeleteSelectedMapSymbolsCommand}"/>
                        </ContextMenu>
                    </ItemsControl.ContextMenu>
                </ItemsControl>
            </Grid>
...

In the Constructor of the view, I set up the DragAndDropEvents:
RadDragAndDropManager.SetAllowDrop(mapAreaItemsControl , true);
RadDragAndDropManager.AddDropQueryHandler(mapAreaItemsControl, new EventHandler<DragDropQueryEventArgs>( OnDropQuery ) );
RadDragAndDropManager.AddDropInfoHandler(mapAreaItemsControl, new EventHandler<DragDropEventArgs>( OnDropInfo ) );

What I am seeing with this is that OnDropQuery fires once and I set the query result to true to enable the drop.
private void OnDropQuery( object sender, DragDropQueryEventArgs e )
{    
    e.QueryResult = true;
    e.Handled = true;
}

I expect that the drag status should be allowed at this point, but its being set to DropImpossible.

I did notice that the OnDropInfo event is being fired twice - the first time, the drag status is DropPossible, but the second time, the drag status is DropImpossible.  The sender both times is the items control and this happens weather the items control is empty or not.  I have tried several combinations of allowing drop to the containing grid, the image, the item control and all of them, but the result is the same.  

Here is the call stack when drop status is DropPossible:
> XXXXXXXXX.OnDropInfo(object sender, Telerik.Windows.Controls.DragDrop.DragDropEventArgs e) Line 57 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.DragDropEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) Line 46 C#
  [External Code]
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.DragDropProvider_DropInfo(object sender, Telerik.Windows.Controls.DragDrop.DragDropEventArgs e) Line 311 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.DragDropProviderBase.RaiseDropInfo() Line 215 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.DragDropProvider.OnElementDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) Line 247 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) Line 182 C#
  [External Code]
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.IInputElementExtensions.RaiseEvent(System.Windows.DependencyObject d, System.Windows.RoutedEventArgs routedEventArgs) Line 83 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragDropManager.DelegateHelper.OnDragEventHandler(object sender, System.Windows.DragEventArgs e) Line 1731 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragDropManager.DelegateHelper.OnOver(object sender, System.Windows.DragEventArgs e) Line 1807 C#
  [External Code]
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(System.Windows.DependencyObject dragSource, object data, System.Windows.DragDropEffects allowedEffects, System.Windows.DragDropKeyStates initialKeyState, object dragVisual, System.Windows.Point relativeStartPoint, System.Windows.Point dragVisualOffset) Line 1018 + 0xe bytes C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.StartDrag() Line 238 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(System.Windows.UIElement sender) Line 191 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(object sender, System.Windows.Input.MouseEventArgs e) Line 163 + 0x1e bytes C#
  [External Code]



Here is the call stack when drop status is DropImpossible:
> XXXXXXX.OnDropInfo(object sender, Telerik.Windows.Controls.DragDrop.DragDropEventArgs e) Line 56 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.DragDropEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) Line 46 C#
  [External Code]
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.RadDragAndDropManager.DragDropProvider_DropInfo(object sender, Telerik.Windows.Controls.DragDrop.DragDropEventArgs e) Line 311 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.DragDropProviderBase.RaiseDropInfo() Line 215 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.DragDropProviderBase.NotifyPreviousApprovedDestination() Line 372 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.DragDropProviderBase.OnDropImpossible() Line 403 + 0xb bytes C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.DragDrop.DragDropProvider.OnElementDragLeave(object sender, Telerik.Windows.DragDrop.DragEventArgs args) Line 295 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) Line 182 C#
  [External Code]
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.IInputElementExtensions.RaiseEvent(System.Windows.DependencyObject d, System.Windows.RoutedEventArgs routedEventArgs) Line 83 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragDropManager.DelegateHelper.OnDragEventHandler(object sender, System.Windows.DragEventArgs e) Line 1731 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragDropManager.DelegateHelper.OnLeave(object sender, System.Windows.DragEventArgs e) Line 1797 C#
  [External Code]
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(System.Windows.DependencyObject dragSource, object data, System.Windows.DragDropEffects allowedEffects, System.Windows.DragDropKeyStates initialKeyState, object dragVisual, System.Windows.Point relativeStartPoint, System.Windows.Point dragVisualOffset) Line 1018 + 0xe bytes C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.StartDrag() Line 238 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(System.Windows.UIElement sender) Line 191 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(object sender, System.Windows.Input.MouseEventArgs e) Line 163 + 0x1e bytes C#
  [External Code]


As noted, Ive tried several combinations of allowing and handling the drag drop events for all of the elements in the view, I cannot get the result to remain DragPossible so that I can actually perform the drop.


Petar Mladenov
Telerik team
 answered on 03 Aug 2012
2 answers
226 views
Hi All,
    I have an issue where I am binding my ViewModel to the TreeView and using a hierarchical data template to allow a self referencing list of items.

I have got this all working fine - however, when I add a new item to the source list, it causes the itemssource on the treeview to be re-evaluated. This in turn calls the converter (which is using a linq query to find the top level of the tree and children).

I think that by calling this converter, the TreeView is losing track of which items were expanded because when the control refreshes, the TreeView is collapsed

This is my converter code (pretty simple):
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
       {
           var item = value as Structure;
           var items = value as SturctureCollection;
 
           if (items != null)
           {
               return items.Where(i => i.ParentID == 0);
           }
           else if (item != null)
           {
               var parent = (item.Parent as StructureCollection);
 
               return parent.Where(i => i.ParentID == item.ID);
           }
 
           return null;
       }

Any idea if this is easily recitified with an option on the control? If not I assume I will need to track which items are expanded (I was thinking about just putting the IDs in a list and iterating), if so which event is best to use when the underlying itemssource is re-evaluated?

Thanks,
Charles
Petar Mladenov
Telerik team
 answered on 03 Aug 2012
1 answer
88 views
We have started using the Telerik RadControls in our latest WPF application, but our test team are having a few issues when using QTP 11.0 to create automated UI tests for some of the controls.

Specifically, when a RadComboBox is made editable, they can't get QTP to enter text with the 'type' command (which works with a regular WPF ComboBox) as it complains it can't focus on the control. Also with the RadGridView control it doesn't seem to pick the grid up at all, just individual cells.

Has anyone else had any luck using QTP with the WPF RadControls? Any tips or QTP plugins that anyone is aware of?

Thanks for any help,

John
Ivan Ivanov
Telerik team
 answered on 03 Aug 2012
1 answer
79 views
I want to add user control in grid view header template. please guid
Shradha
Top achievements
Rank 1
 answered on 03 Aug 2012
1 answer
338 views
Hello,

I'm using Telerik RadControls for WPF 2012.2.725.40. I have a RadListBox with a DataTemplate for the items. In the DataTemplate I have a TextBox and I want to achieve that when the user clicks inside the TextBox, the ListBoxItem gets selected. So, I made a Style:

<Style TargetType="{x:Type telerik:RadListBoxItem}">
    <Style.Triggers>
        <Trigger Property="IsKeyboardFocusWithin" Value="True">
            <Setter Property="IsSelected" Value="True" />
        </Trigger>
    </Style.Triggers>
</Style>

This works fine with standard WPF ListBox but not with RadListBox/RadListBoxItems.

The full source:
<Window x:Class="IsKeyboardFocusWithin.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <DataTemplate x:Key="ListBoxItemTemplate">
            <TextBox Text="aasdf asdf asdf asdf asf " />
        </DataTemplate>
 
        <Style TargetType="{x:Type ListBoxItem}">
            <Style.Triggers>
                <Trigger Property="IsKeyboardFocusWithin" Value="True">
                    <Setter Property="IsSelected" Value="True" />
                </Trigger>
            </Style.Triggers>
        </Style>
 
        <Style TargetType="{x:Type telerik:RadListBoxItem}">
            <Style.Triggers>
                <Trigger Property="IsKeyboardFocusWithin" Value="True">
                    <Setter Property="IsSelected" Value="True" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
     
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
         
        <ListBox x:Name="lstList" ItemTemplate="{StaticResource ListBoxItemTemplate}" VerticalContentAlignment="Stretch" ItemsSource="{Binding}"
                            SelectionMode="Single" />
 
        <telerik:RadListBox x:Name="lstTelerikList"
                            ItemTemplate="{StaticResource ListBoxItemTemplate}" VerticalContentAlignment="Stretch" ItemsSource="{Binding}"
                            SelectionMode="Single"
                            Grid.Row="1"/>
    </Grid>
</Window>

and the code-behind:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        Items = new ObservableCollection<string>() { "Item 1", "Item 2", "Item 3" };
        InitializeComponent();
        lstList.DataContext = Items;
        lstTelerikList.DataContext = Items;
    }
 
    public ObservableCollection<string> Items
    {
        get;
        set;
    }
}

Am I doing something wrong?
Masha
Telerik team
 answered on 03 Aug 2012
10 answers
289 views
I've got data loaded in the RadGridView control that I want to export to Excel. This is working just fine, using the .ToCSV method. However what I'm searching for is way to tell Excel to treat a column as a Text instead of General.

One of the columns is a bar code number. This number can start with a zero, like 0123456789.

After the export Excel cuts off the first zero because it is formatting it as a General and I get 123456789. I know I can reformat in Excel to custom format. But this should not be necessary.

Any recommendations?

I've tried setting DataFormatString to "{}{0:000000000000}", but this does not work. I did see a previous post that describes a bug in DataFormatString and I'm using 2010_1_0309 version of RadControls, which I think is a older version.

Thanks ...
Nikita
Top achievements
Rank 1
 answered on 03 Aug 2012
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?