Telerik Forums
UI for WPF Forum
1 answer
356 views

Hello Team,

I've got a Listbox and a GridLayout. The GridLayout is hosted by an ItemsControl and styled by a DataTemplate. This works fine.
Now the user should be able to drag an item from the listbox into the GridLayout. This works too, but only if the payload is being dropped on the TextBlock. Otherwise the DragStatus is always DropImpossible. It should be possible to drop the payload anywhere into the grid cell.

I have studied the examples but I can't get it to work.
Could please have a look at my code?


<Page.Resources>
    <DataTemplate DataType="{x:Type local:ViewModelRasterElement}">
        <Border BorderBrush="#EFEFEF" BorderThickness="1"
                telerikDragDrop:RadDragAndDropManager.AllowDrop="True"
                telerikDragDrop:RadDragAndDropManager.AllowDrag="True">
             
                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center"
                           Text="{Binding Bezeichnung}"/>
        </Border>
    </DataTemplate>
 
    <DataTemplate x:Key="ApplicationDragTemplateTextbox">
        <TextBox Width="200" Height="20"/>
    </DataTemplate>
    <DataTemplate x:Key="ApplicationDragTemplateLabel">
        <Label Background="Yellow" Content="Ziehen Sie den in eine bliebige Zelle"/>
    </DataTemplate>
</Page.Resources>


<ItemsControl ItemsSource="{Binding RasterElemente}">
    <ItemsControl.ItemContainerStyle>
        <Style>
            <Setter Property="Grid.Row" Value="{Binding GridRow}" />
            <Setter Property="Grid.Column" Value="{Binding GridColumn}" />
        </Style>
    </ItemsControl.ItemContainerStyle>
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Grid ShowGridLines="false"
                  telerikDragDrop:RadDragAndDropManager.AllowDrop="True"
                  telerikDragDrop:RadDragAndDropManager.AllowDrag="True">
                <Grid.RowDefinitions>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="130"/>
                    <ColumnDefinition Width="130"/>
                    <ColumnDefinition Width="130"/>
                    <ColumnDefinition Width="130"/>
                    <ColumnDefinition Width="130"/>
                    <ColumnDefinition Width="130"/>
                    <ColumnDefinition Width="130"/>
                    <ColumnDefinition Width="130"/>
                </Grid.ColumnDefinitions>
            </Grid>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

And here the code behind:

public ViewTest()
{
    InitializeComponent();
 
    RadDragAndDropManager.AddDragQueryHandler(this, OnDragQuery);
    RadDragAndDropManager.AddDropQueryHandler(this, OnDropQuery);
    RadDragAndDropManager.AddDropInfoHandler(this, OnDropInfo);
}
 
private void OnDropInfo(object sender, DragDropEventArgs e)
{
    Console.WriteLine(e.Options.Status);
    if (e.Options.Status == DragStatus.DropComplete)
    {
        string typ = e.Options.Source.GetType().ToString();
        switch (typ)
        {
            case "System.Windows.Controls.ListBox":
                {
                    if (e.Options.Payload != null)
                    {
                        ViewModelRasterElement element = (ViewModelRasterElement)e.Options.Destination.DataContext;
                        element.Bezeichnung = e.Options.Payload.ToString();
                    }
                }
                break;
            default:
                break;
        }
    }
    e.Handled = true;
}
 
void OnDropQuery(object sender, DragDropQueryEventArgs e)
{
    Console.WriteLine(e.Options.Status);
    Console.WriteLine(e.Options.Destination.DataContext.GetType().ToString());
     
    if (e.Options.Destination.DataContext is ViewModelRasterElement &&
        e.Options.Status == DragStatus.DropDestinationQuery)
    {
        e.QueryResult = true;
    }
    e.Handled = true;
    Console.WriteLine(e.QueryResult);
}
 
protected virtual void OnDragQuery(object sender, DragDropQueryEventArgs e)
{
    string typ = e.Options.Source.GetType().ToString();
    switch (typ)
    {
        case "System.Windows.Controls.ListBox":
            {
                ListBox listbox = (ListBox)e.Options.Source;
                if (listbox.SelectedItem != null)
                {
                    if (e.Options.Status == DragStatus.DragQuery)
                    {
                        e.Options.Payload = listbox.SelectedItem;
                        ContentControl cue = new ContentControl();
                        cue.ContentTemplate = this.Resources["ApplicationDragTemplateLabel"] as DataTemplate;
                        cue.Content = listbox.SelectedItem;
                        e.Options.DragCue = cue;
                        e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
                    }
                }
            }
 
            break;
        default:
            break;
    }
 
    e.Handled = true;
    e.QueryResult = true;
}


Thank you for your assistance.

Best regards

Josef
Arthur
Top achievements
Rank 1
 answered on 07 Jan 2013
14 answers
282 views

Hi Petar,  as we have discussed previously, my app receives data from remote sources and I add it to a chart in the elapsed event of a timer.  The timer that updates the chart runs continuously however there are often periods of time when no data is received.  For those periods I want to display the X axis label (i.e. the time) and a blank space where the bar should be.  So, for long periods of time where no data is received the user should simply see the x axis labels scrolling to the left (no bars) as the chart is updated.  Please note in my app that there are no series initially defined for my chart.  The reason for that is that the series are linked to a property of the data and until I have data to display I don’t know what series to display.

Having said that, there are two  issues which I would like to bring to your attention and attempt to resolve:
1.)  When the application is first loaded there is no data and no series as described above.  I add a series with Y values = 0 and X values containing time periods in the past (the labels on the X axis are time stamps).  The purpose of adding this series is to  overcome issues with bar width that I have asked about in prior posts, and also to act as a placeholder for time periods (bars) where there is no data.  My intent is that the X axis labels should ALWAYS appear on the chart, but the bar fragments for this placeholder series should never appear on the chart (the Y values are always zero).  The problem is that when there is no data there is no Y axis so the placeholder series is plotted at the full height of the chart even though the values are zero.  How do I suppress plotting the bars for this series but keep the X axis labels?  Ideally I would like a Y axis scale to always appear on the chart.  If I could initially set that scale to have a max of, say, 1 that would cause the zero value placeholder series to have no height which would work just fine.

2.) When all data scrolls off the left side of the chart, new bars are not plotted when data is received.  This issue can be reproduced as follows:

Load the attached app and click Start Generating Data.

Wait until a few bars are generated then click Stop Generating Data.
Wait until all bars have scrolled off the left side of the chart. Notice that the placeholder series is plotted at full height (this is the issue described above).
Click Start Generating Data.  Notice that no bars are plotted.

Repeat the above steps but do not allow all data to scroll off the left side of the chart.  When you click Start Generating Data again, data will plot as expected.

I found that adding a placeholder row in my data collection will work around this issue.  Uncomment the following code in the AddLoadStatistic method.  However I am not certain this is a fix, or perhaps I am doing something else that’s wrong that is causing this issue (???).

if (LoadSources.Count > 0)
            {
                foreach (System.Collections.DictionaryEntry key in LoadSources)
                    LoadStatistics.Add(new LoadStatistic { PeriodEnding = LoadIntervalEndTime, Source = key.Key.ToString() });
            }
            else

Sam
Top achievements
Rank 1
 answered on 07 Jan 2013
6 answers
274 views
Hi

I would like to avoid deselecting currently selected shape while clicking on the diagram.
When you click on the diagram, out of a shape, the currently selected shape is deselected.
I couldn't find a way to configure or do that.
Thanks for your help.

Cheers
Laurent Kempé
Laurent Kempé
Top achievements
Rank 2
 answered on 07 Jan 2013
3 answers
398 views
I have created a RadPanelBar with two items. I want the DefaultItem to be selected by default. How can I do that dynamically?
Below is the xaml code for RadPanelBar

<
telerik:RadPanelBar x:Name="mybar" Width="252" Height="500" HorizontalAlignment="Left"  VerticalAlignment="Top" ExpandMode="Single" Margin="0,58,0,0" SelectedItem="{Binding PanelBarItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                <telerik:RadPanelBarItem x:Name="DefaultItem" >
                    <telerik:RadPanelBarItem.Header>
                        <TextBlock Text="Default Item" />
                    </telerik:RadPanelBarItem.Header>
                </telerik:RadPanelBarItem>
                <telerik:RadPanelBarItem x:Name="ExpandItem" >
                    <telerik:RadPanelBarItem.Header>
                        <TextBlock Text="Expand Item" />
                    </telerik:RadPanelBarItem.Header>
 
                    <ListBox Height="200" Margin="1,17,1,143" ItemsSource="{Binding TList}" BorderBrush="Transparent" BorderThickness="0"  SelectedItem="{Binding SelectedTool, Mode=TwoWay}"
                             >
                    </ListBox>
                </telerik:RadPanelBarItem>
 
            </telerik:RadPanelBar>

I also want the first item in the TList to be selected by default when ExpandItem is selected. Please help with this. 
Thanks in Advance 
Tina Stancheva
Telerik team
 answered on 07 Jan 2013
4 answers
134 views
Hello,
Is there a way to allow user input into AutoCompleteBox (text that is not in the list)?
Jasna
Top achievements
Rank 1
 answered on 07 Jan 2013
1 answer
593 views
Is there a way to get the current Text of the RadAutoCompletBox?  It appears to me that you currently need to bind to both SearchText and Selected Item which doesn't feel right to me.  Here is an example of my xaml

<telerik:RadAutoCompleteBox SelectionMode="Single" 
                                    ItemsSource="{Binding Items}" 
                                    SearchText="{Binding SearchText, Mode=TwoWay}" 
                                    SelectedItem="{Binding SelectedItem, Mode=TwoWay}" />

Items is just a List<string>

Say for instance we are looking for the string "telerik".  I type in "te" then hit tab key, the autocompletebox text is telerik.. however if i look at the SearchText it is just "te" and the SelectedItem is telerik.  Which leads me to have to check if SelectedItem is null then use SearchText else use SelectedItem.  Am i missing something here?  Seems like i should be able to just bind to the Text.

I am currently using RadControls for WPF v.2012.1224.40 (Dev)
Vladi
Telerik team
 answered on 07 Jan 2013
1 answer
236 views
Hi,

I am having difficulties in specifying the Expression property of the GridViewExpressionColumn in Xaml.
I have this column that I want to turn into a expression column :
<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Attributes.[PERCEELID]}" Header="PerceelId" DataType="{x:Type sys:Int32}" />
First step, make ik a GridViewExpressionColumn :
<telerik:GridViewExpressionColumn UniqueName="Opp" Header="Oppervlakte (ha)" Expression="Attributes[&quot;PERCEELID&quot;]" />
So far so good, this still displays the same result as my original column (nothing calculated so far).
But as soon as I want to do something with this value, nothing is shown and I receive errors in the output window.
This is about the simplest expression I can think of (multiplying by 2) :
<telerik:GridViewExpressionColumn UniqueName="Opp" Header="Oppervlakte (ha)" Expression="Attributes[&quot;PERCEELID&quot;] * 2" />
The column stays empty and the outpunt window shows :

A first chance exception of type 'System.ArgumentException' occurred in System.ComponentModel.DataAnnotations.dll

A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll


I have tried to explicitely cast my value first before multiplying (Convert.ToInt32(Attributes[&quot;PERCEELID&quot;]) * 2); but no success.

If I do the same in code-behind, there is no problem :
    Expression<Func<Graphicdouble>> expression = g => (int)g.Attributes["PERCEELID"] * 2;
    var c = this.GevondenPercelenDataGrid.Columns["Opp"as GridViewExpressionColumn;
    c.Expression = expression;


The ToString() of this expression yields:

"g => Convert((Convert(g.Attributes.get_Item(\"PERCEELID\")) * 2))"

Using this string as value for "Expression" in the xaml is no solution either.





Can anyone give me some tips on building expressions in xaml ?



 





Kind regards,



















Martin



Rossen Hristov
Telerik team
 answered on 07 Jan 2013
3 answers
193 views

I have a RadCombox with IsFilteringEnabled =True and CanAutocompleteSelectItems = False
When I open the drop down, I can starting typing in the text box to filter the listing but nothing is selected until I press enter. If I decide to cancel the filtering by closing the drop down, the text that I typed stilled remains.

How can I get the text to revert back to the selected item?
I tried UpdateTarget in the code-behind but since the selection has not changed, this had no affect.

Yana
Telerik team
 answered on 07 Jan 2013
22 answers
554 views
I have a RadDatePicker in which I set IsTabStop="True" and TabIndex=4.
However, this does not work the way I expected it to.
As TabStop #4 The whole RadPicker is selected - and I can no "do" anything but move on - there's no way to type text in the TextBox or open the picker dialog.
However at the end of my hand-set-tab-order the tab jumps into the the RadDatePicker-TextBox to edit the date.

How can I make the RadDatePicker-TextBox be part of my TabOrder ??

I am using the RadControls for wpf 2009.Q2

yours,
Nils
Boyan
Telerik team
 answered on 07 Jan 2013
3 answers
330 views
Hi,

since my last Update with the "TelerikControlPanelSetup_2012_2_718", one menue item is missing im my visual studio 2010!
How can i restore it?

Missing Item:

Telerik - RadControls for WPF

Thanks
Best Regards
Rene
ITA
Top achievements
Rank 1
 answered on 07 Jan 2013
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?