Telerik Forums
UI for WPF Forum
1 answer
892 views

I'm just getting into this and I just can't figure out what I am doing wrong.

I have the following XAML (at least the relevant part) followed by the code in the Viewmodel to load it.

In the seachcommand function I make a db call and load the results into my observable collection of SearchResultBag.

The query runs fun and I get data. It just doesn't show in the grid. What is the magic sauce I am missing. This seems like it should be trivial.

If I get rid of the SearchResultsBag and ONLY return a string (for testing purposes) the string(s) get displayed in the grid. Why won't my SearchResultsBag display it's contents. I've been a good boy and defined the template columns. It's gotta be something simple but I just can't see what I am missing.

While I'm at it, can anyone point me to a good MVVM databound RadGridView example. The telerik demo app is WAAAAY to complicated for a newb like me to pick up the basics from. I'm sure if I can get this simple search thing working I can get the rest.

Thanks ... Ed

 

<Button x:Name="cmdSearch"  Grid.Row="8" Grid.Column="1"        Content="Search" HorizontalAlignment="Left"         Command="{Binding SearchCommand }" Margin="0,5,0,5"/>


<telerik:RadGridView Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="3" x:Name="ssSearch"
     Visibility="{Binding ShowResults, Converter={StaticResource bResultsVisibleConverter}}"
     ItemsSource="{Binding SearchResults, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay }"
     Height="200"
                     >
             <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Request #" DataMemberBinding="{Binding CustomKey}"/>
                <telerik:GridViewDataColumn Header="ClientName" DataMemberBinding="{Binding ClientName}"/>
                <telerik:GridViewDataColumn Header="ClientId" DataMemberBinding="{Binding ClientId}"/>
                <telerik:GridViewDataColumn Header="OpenedBy" DataMemberBinding="{Binding OpenedBy}"/>
                <telerik:GridViewDataColumn Header="ProjectId" DataMemberBinding="{Binding ProjectId}"/>
                <telerik:GridViewDataColumn Header="OpenedDate" DataMemberBinding="{Binding OpenedDate}"/>
                <telerik:GridViewDataColumn Header="RequestedDate" DataMemberBinding="{Binding RequestedDate}"/>
                <telerik:GridViewDataColumn Header="CloseDate" DataMemberBinding="{Binding CloseDate}"/>


            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

 

 

SearchCommand = new Prism.Commands.DelegateCommand(Search).ObservesProperty(() => SearchResults);
private ObservableCollection<SearchResultsBag> _searchResults;

public ObservableCollection<SearchResultsBag> SearchResults
{
get { return _searchResults; }
set { SetProperty(ref _searchResults, value); }
}
private void Search()
{
this.SearchResults = new ObservableCollection<SearchResultsBag>();
var q = from a in db.CALMS_Request
where a.Custom_Key == CustomKey
select new SearchResultsBag
{
CustomKey = a.Custom_Key,
ClientName = a.Client.ClientName,
ClientId = a.Client.ClientId.ToString(),
OpenedBy = "OpenedBy",
ProjectId = a.ProjectID,
OpenDate = a.DateCreated.ToString(),
RequestedDate = a.RequestedDate,
CloseDate = a.ClosedDate
};
if (string.IsNullOrWhiteSpace(CustomKey))
q = q.Where(a => a.CustomKey.ToLower() == CustomKey.ToLower());


foreach (SearchResultsBag item in q)
this.SearchResults.Add(item);
ShowResults = true;
}
public class SearchResultsBag
{
public string CustomKey;
public string ClientName;
public string ClientId;
public string OpenedBy;
public string ProjectId;
public string OpenDate;
public string RequestedDate;
public string CloseDate;
}

 

Stefan Nenchev
Telerik team
 answered on 14 Nov 2016
0 answers
85 views

How can you cancel a drag and drop operation when the item isn't in the correct category?

Arne
Top achievements
Rank 1
 asked on 14 Nov 2016
1 answer
181 views

Hi

Can you give a code sample to add a new table from which is dragged from treeview to sqldiagram & also add table & columns from code behind not from xml.

 

 

Dinko | Tech Support Engineer
Telerik team
 answered on 14 Nov 2016
1 answer
117 views

Hello,

By analyzing these logs this morning, we have discovered a new type of error that causes our application to fail many times by a day at one of our clients, the error shows that the interop class Windows was called by the graphics library Telerik.

 

2016-11-08 09:55:02,344 [1] ERROR Logger -
System.TypeInitializationException: Une exception a été levée par l'initialiseur de type pour 'Telerik.Windows.Controls.InternalWindow.Standard.DpiHelper'. ---> System.ComponentModel.Win32Exception: L’opération a réussi
   à Telerik.Windows.Controls.InternalWindow.Standard.NativeMethods.GetDC(IntPtr hwnd)
   à Telerik.Windows.Controls.InternalWindow.Standard.DpiHelper..cctor()
   --- Fin de la trace de la pile d'exception interne ---
   à Telerik.Windows.Controls.InternalWindow.Standard.DpiHelper.DevicePixelsToLogical(Point devicePoint)
   à Telerik.Windows.DragDrop.DragDropManager.UpdateWindowLocation()
   à Telerik.Windows.DragDrop.DragDropManager.CreateDragDropWindow(Object content)
   à Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects, DragDropKeyStates initialKeyState, Object dragVisual, Point relativeStartPoint, Point dragVisualOffset)
   à Telerik.Windows.DragDrop.DragInitializer.StartDrag()
   à Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(UIElement sender)
   à Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(Object sender, MouseEventArgs e)
   à System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   à System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   à System.Windows.Input.InputManager.ProcessStagingArea()
   à System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   à System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   à System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   à System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   à System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   à System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

 

Did you ever experience this problem?

Kalin
Telerik team
 answered on 14 Nov 2016
3 answers
394 views

Hi,

I have a little problem. I put RadPanel in application based on Visual Studio theme with the following code.

    <StackPanel x:Name="NavigationStackPanel">
        <telerik:RadPanelBar
            x:Name="NavigationPanel"
            AutoScrollToSelectedItem="True"
            BringIntoViewMode="HeaderAndItems"
            ExpandMode="Multiple" SelectionMode="Single"
            ItemsSource="{Binding Path=ApplicationNodes}"
            ItemTemplate="{StaticResource PanelBarHeaderTemplate}"
            SelectionChanged="NavigationPanel_SelectionChanged"
            BorderThickness="0"
            ScrollViewer.HorizontalScrollBarVisibility="Visible"
            ScrollViewer.VerticalScrollBarVisibility="Visible" />
    </StackPanel>

 

Unfortunately, scroll does not work properly as you can see on the screenshots. Any ideas how I can fix it?

Milena
Telerik team
 answered on 11 Nov 2016
2 answers
66 views
Can I use RadTileViewItem that is inside RadTileView as a container for RadCartesianChart ? Will RadTileView support all functionality of RadCartesianChart in this case?
Dmitry
Top achievements
Rank 1
 answered on 10 Nov 2016
1 answer
123 views

Hi there,

Is it possible to resize a row number column (the first column) like other columns?

please reply it!

 

Dilyan Traykov
Telerik team
 answered on 10 Nov 2016
1 answer
176 views

Hello,

I have a GridView with large number of data. I am using Datapager for pagination having 100 records per page. On click of next page I download the next 100 records.

Problem :- Inbuilt sorting, sorts the whole gridview but I want to sort only the current page not the whole grid, as other pages may not have data.

While sorting with other pages as blank, results in null values shown up at the top of the grid.

 

Any help appreciated!
Thanks,

Ivan Ivanov
Telerik team
 answered on 10 Nov 2016
1 answer
102 views

Hi there,

 

I'm having trouble adding new data row or changing data on the grid view.

I can't see new data row when the grid view is filled.

I think the data row is filled as other data rows. 

I'd like new data row to ignore the filtering and sorting when it is added.

Could you give us some advice how to fix this issue?

 

please reply it.

Stefan Nenchev
Telerik team
 answered on 10 Nov 2016
13 answers
241 views

Hi everyone,

I am trying to use Telerik Testing Framework to automate tests fpr a WPF application that has a drag and drop style "pallette" created using GoXam. I originally started using TestStudio, but got mixed results (sometimes the elements would be dragged and droppe, but not always), I believe that this is because it finds the elements based on location data.

I want to find the elements in the canvas via element data (automationId, type, text etc.), but whenever I try and search for an element by these attributes I get an element not found error. I tried with various different ways of finding the element (Find.ByTextContent, Find.ByAutomationID, Find.ByXamlExpression), but I always seem to get an element not found error.

I have posted my test and the section of the xaml that holds the element that I want to drag and drop below.

Any help would be hugely appreciated.

David

 

Xaml Section:

<DataTemplate x:Key="GroupTemplate">
                <Border BorderThickness="2" Background="{Binding Path=Data.Color}"
              BorderBrush="{Binding Path=Data.Color}"
              go:Part.SelectionAdorned="True"
              go:Part.Resizable= "{Binding Path=Data.Resizable, Mode=TwoWay}"
              go:Node.LocationElementName="myGroupPanel"
              go:Group.IsSubGraphExpanded="{Binding Path=Data.IsSubGraphExpanded, Mode=TwoWay}"
              go:Part.DropOntoBehavior="AddsToGroup">
                    <StackPanel Background="{Binding Path=Node.IsDropOntoAccepted, Converter={StaticResource theBrushChooser}}">
                        <StackPanel AutomationProperties.AutomationId="Canvas_Element" Orientation="Horizontal" HorizontalAlignment="Left">
                            <Button x:Name="myCollapseExpandButton"                                
                            Content="{Binding Path=Group.IsExpandedSubGraph, Converter={StaticResource theButtonConverter}}"
                            Width="20" Margin="0 0 5 0" Visibility="{Binding Path=Data.Visibility}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <i:InvokeCommandAction Command="{Binding Path=DataContext.CollapseExpandCommand, 
                                        RelativeSource={RelativeSource AncestorType={x:Type local:HierarchicalView}}, Mode=OneWay}" 
                                        CommandParameter="{Binding Path=Group}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                            <TextBox Text="{Binding Path=Data.Name}" FontWeight="Bold" go:Part.TextEditable="{Binding Path=Data.Editable}" FontSize="20" x:Name="TextBox" 
                                 IsEnabled="{Binding Path=Data.Editable}" Background="{Binding Path=Data.Color}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="LostFocus">
                                        <i:InvokeCommandAction Command="{Binding Path=DataContext.LostFocusCommand, 
                                        RelativeSource={RelativeSource AncestorType={x:Type local:HierarchicalView}}, Mode=OneWay}" 
                                        CommandParameter="{Binding Path=Node}"/>
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="GotFocus">
                                        <i:InvokeCommandAction Command="{Binding Path=DataContext.GotFocusCommand, 
                                        RelativeSource={RelativeSource AncestorType={x:Type local:HierarchicalView}}, Mode=OneWay}" 
                                        CommandParameter="{Binding Path=Node}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </TextBox>
                            <ComboBox Height="20" Width="75" x:Name="combo" Margin="20 0 0 0" ItemsSource="{Binding Path=Data.Elements}" Visibility="{Binding Path=Data.Visibility}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <i:InvokeCommandAction Command="{Binding Path=DataContext.SelectionChangedComboCommand, 
                                        RelativeSource={RelativeSource AncestorType={x:Type local:HierarchicalView}}, Mode=OneWay}" 
                                        CommandParameter="{Binding Path=Node}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </ComboBox>
                        </StackPanel>
                        <go:GroupPanel x:Name="myGroupPanel" Padding="5" SurroundsMembersAfterDrop="True" />

                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Drop">
                                <i:InvokeCommandAction Command="{Binding Path=DataContext.DropNodeCommand, 
                                            RelativeSource={RelativeSource AncestorType={x:Type local:HierarchicalView}}, Mode=OneWay}" 
                                            CommandParameter="{Binding Path=Node}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>

                    </StackPanel>
                    <go:Group.Layout>
                        <go:GridLayout WrappingColumn="1" CellSize="1 1" Conditions="Standard GroupSizeChanged"/>
                    </go:Group.Layout>
                </Border>
            </DataTemplate>
        </go:DataTemplateDictionary>

 

 

Test:

using ArtOfTest.WebAii.Controls.Xaml.Wpf;
using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.Silverlight;
using ArtOfTest.WebAii.TestTemplates;
using ArtOfTest.WebAii.Wpf;
using ArtOfTest.WebAii.Xaml;
using ArtOfTest.WebAii.TestAttributes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ArtOfTest.WebAii.Controls.HtmlControls;
using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
using ArtOfTest.WebAii.Controls.Xaml.Wpf;


namespace UnitTestProject2
{

    [TestClass]
    public class TelerikNUnitTest1 : BaseWpfTest
    {

        private TestContext testContextInstance;

        public WpfApplication foo_app { get; private set; }


        [TestMethod]
        public void Open_Application()
        {
            
            //TestContext.WriteLine("Start Unit Test");
            /// Create my own Settings object and then modify the defaults
            Settings mySettings = new Settings();
            mySettings.ClientReadyTimeout = 60000;

            /// Use my Settings object to construct my Manager object
            Manager myManager = new Manager(mySettings);
            myManager.Start();

            // Launch the application instance from its location in file system
            WpfApplication foo_app = myManager.LaunchNewApplication(@"C:\PathTo\Startup.exe");
            //TestContext.WriteLine("Opened application");

            /// Validate the title of the homepage
            ArtOfTest.Common.UnitTesting.Assert.IsTrue(foo_app.MainWindow.Window.Caption.Equals("MainWindow"));
            //TestContext.WriteLine("Validated window");

            ///Click the new project button
            FrameworkElement newProjButton = foo_app.MainWindow.Find.ByTextContent("New project...");
            //TestContext.WriteLine("Found element");
            newProjButton.User.Click();

            ///Send keys to the project name textbox
            FrameworkElement projNameTextBox = foo_app.MainWindow.Find.ByAutomationId("New_Proj_Text_Box");

            projNameTextBox.Wait.ForNoMotion(5000);
            projNameTextBox.User.Click();
            projNameTextBox.User.TypeText("PokeMoon", 100);
                 
            ///Select the View family
            FrameworkElement viewElement = foo_app.MainWindow.Find.ByTextContent("View");
            viewElement.User.Click();

            ///Click the "Create" Button 
            FrameworkElement createButton = foo_app.MainWindow.Find.ByTextContent("Create");
            createButton.User.Click();

            /// Wait for the canvas to load 
            FrameworkElement hierarchicalViewPage = foo_app.MainWindow.Find.ByAutomationId("Hierarchical_View");
            hierarchicalViewPage.Wait.ForExists();

            ///Click on the PROCESS element and then drag it into the canvas
///This is where I cannot find the element.
            FrameworkElement processElement = foo_app.MainWindow.Find.ByExpression(new XamlFindExpression("Key='GroupTemplate'", "|", "textcontent='PROCESS', "|", 'AutomationProperties.AutomationId='Canvas_Element'" ")).As<FrameworkElement>(); ;

            processElement.Wait.ForNoMotion(5000);
            processElement.User.Click();
            processElement.User.DragTo(100, 100);
        }

    }

}

Georgi
Telerik team
 answered on 10 Nov 2016
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
Slider
Expander
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
WebCam
CardView
DataBar
Licensing
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
HighlightTextBlock
Security
TouchManager
StepProgressBar
VirtualKeyboard
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?