Telerik Forums
UI for WPF Forum
0 answers
188 views
Hi,
I am trying to create a program that will have a listbox on the left of database table names and then a grid area to the right.

When the user double clicks on a table name  a grid with the table data should be populated with the table data. Once it is open the user should be able to make changes and hit the save button that will submit the datacontext changes.

I have a linq to sql set up for the Northwind database for this example.

As soon as I make a change in the grid to a cell the entire row disappears??? not sure what I am doing wrong.

Thanks,
Jessica 
DataProvider.cs
 
 
 
namespace SampleLinqToSQL
{
    public static class DataProvider
    {
        private static NorthwindDataContext dataContext = null;
 
        public static NorthwindDataContext DataContext
        {
            get
            {
                return dataContext;
            }
        }
 
        static DataProvider()
        {
            dataContext = new NorthwindDataContext();
        }
 
        public static void SetDataContext(string connectionString)
        {
            dataContext = null;
            dataContext = new NorthwindDataContext(connectionString);
        }
    }
}


MainWindow.xaml
 
 
<Window x:Class="SampleLinqToSQL.MainWindow"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="350" Width="525">
    <DockPanel LastChildFill="True">
        <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal">
            <Button x:Name="SaveBtn" Width="50" Height="25" Margin="5" Click="SaveBtn_Click">Save</Button>
            <Button x:Name="CancelBtn" Width="50" Height="25" Margin="5" Click="CancelBtn_Click">Cancel</Button>
        </StackPanel>
         
        <ListBox x:Name="TableNames" DockPanel.Dock="Left" Width="140" MouseDoubleClick="TableNames_MouseDoubleClick"></ListBox>
         
        <Border>
            <DockPanel x:Name="DocumentArea">
                <telerik:RadGridView x:Name="dataGridView"  AutoGenerateColumns="True" ItemsSource="{Binding}"  />
            </DockPanel>
        </Border>
    </DockPanel>
</Window>


MainWindow.xaml.cs
 
 
 
namespace SampleLinqToSQL
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private string sqlConnection = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Path\Northwind.mdf;Integrated Security=True;User Instance=True";
        public MainWindow()
        {
            InitializeComponent();
 
            DataProvider.SetDataContext(sqlConnection);
 
            LoadTableNames();
        }
 
        private void LoadTableNames()
        {
            List<string> tableNames = new List<string>();
 
            foreach (PropertyInfo item in DataProvider.DataContext.GetType().GetProperties())
            {
                tableNames.Add(item.Name);
            }
 
            tableNames = tableNames.OrderBy(s => s).ToList();
            TableNames.ItemsSource = tableNames;
        }
 
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            DataProvider.DataContext.SubmitChanges();
        }
 
        private void CancelBtn_Click(object sender, RoutedEventArgs e)
        {
            //TODO
        }
 
        private void TableNames_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (TableNames.SelectedItem != null)
            {
                dataGridView.DataContext = DataProvider.DataContext.GetTableByName(TableNames.SelectedItem.ToString()).AsParallel();
            }
        }
    }
}

Jessica
Top achievements
Rank 1
 asked on 16 Jan 2012
1 answer
134 views
I am using RadRibbonWindow to host a RadRibbonView, and set QuickAccessToolBarPosition to "AboveRibbon", but the QuickAccessToolBar is overlaying the application icon.  How can I shift the QuickAccessToolBar away from the application icon?  
I like to have the same format as Excel 2010 which has a separator between the application icon and the QuickAccessToolBar (please see the attachment).

Thanks.
Viktor Tsvetkov
Telerik team
 answered on 16 Jan 2012
1 answer
170 views
Hello,

I recently updated my application to the 2011 Q3 DLLs. I have a tab control that binds to an ObservableCollection for the ItemsSource. I have to add an item to the ObservableCollection in code. I used to be able to do an UpdateLayout on the tab control, and it would add the new tab. It doesn't do this anymore. I can set the ItemsSource to null and back to the ObservableCollection to get the tab to show up, but that has other very bad consequences in my application.

Have you seen this problem with the UpdateLayout not working? Do you know of a work around?

Thanks,
Scott
Sehe
Top achievements
Rank 1
 answered on 16 Jan 2012
1 answer
87 views
Is there a way to define an item minimized in xaml (so that it appears in the minimize area by default)?

My list is only 3 items and it looks silly to not have any items in the minimized area (using office_blue theme), so I'd like to push my third item there by default (since it's importance is less, it can be hidden away by default).

Petar Mladenov
Telerik team
 answered on 16 Jan 2012
1 answer
398 views

I am using a RadGridView to display some data in a hierarchy. I am using MvvM so I am building by grid in XAML and have very little code behind.

I have a very simple hierarchy where I have a list of objects (Agents) and each agent can have a list of sub agents and a list of clients. These lists are two separate properties of my agent object, i.e. Agent.Agents and Agent.ClientAccounts. An agent can have a list of clients and a list of sub agents so when the user expands an agent row they will see two child grids at the same level in the hierarchy.

I am using the grid_RowLoaded event to only allow expanding when I have either a list of SubAgents or a list of Clients.

My issue is that when one of the lists of either SubAgents or Clients doesn’t have any records I would like to hide the grid (or not even create it in the first place)

I have tried to set the visibility of the SubAgents and Clients  grids by using a converter so the grids are hidden when the lists have a count of 0 but that didn’t work

Any ideas would be much appreciated

Here is the structure of my grid

<telerik:RadGridView 
        x:Name="grid"
        BorderThickness="0"
        Background="Transparent"
        ShowGroupPanel="False" 
        IsReadOnly="True"
        DataContext="{Binding}" 
        ItemsSource="{Binding Path=AgentList}" 
        RowIndicatorVisibility="Collapsed" 
        GridLinesVisibility="None" 
        telerik:Theming.Theme="{DynamicResource TelerikThemeName}" 
        IsSynchronizedWithCurrentItem="True"
        ShowColumnHeaders="True" 
        AutoGenerateColumns="False" 
        acb:CommandBehavior.Event="MouseDoubleClick"  
        acb:CommandBehavior.Command="{Binding OpenAgentDetailsCommand}" 
        acb:CommandBehavior.CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.CustomerId}" RowLoaded="grid_RowLoaded">
 
        <telerik:RadGridView.ChildTableDefinitions>
            <telerik:GridViewTableDefinition/>
        </telerik:RadGridView.ChildTableDefinitions>
 
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding AccountId}" Header="Account Id" Width="Auto" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding CustomerId}" Header="CustomerId" Width="Auto" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="FirstName" Width="Auto"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="LastName" Width="Auto"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Volume}" Header="Volume" Width="Auto" DataFormatString="{}{0:N0}"/>
        </telerik:RadGridView.Columns>
        
        <telerik:RadGridView.HierarchyChildTemplate>
            <DataTemplate>
                <StackPanel>
 
                    <!--sub agents-->
                    <telerik:RadGridView ItemsSource="{Binding Path=Agents}" AutoGenerateColumns="False" ShowGroupPanel="False" 
                                         Visibility="{Binding Path=Agents.Count, Converter={StaticResource countToVisibleConverter}}">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding AccountId}" Header="Account Id" Width="Auto" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding CustomerId}" Header="CustomerId" Width="Auto" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="FirstName" Width="Auto"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="LastName" Width="Auto"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding Volume}" Header="Volume" Width="Auto" DataFormatString="{}{0:N0}"/>
                        </telerik:RadGridView.Columns>
 
                        <telerik:RadGridView.ChildTableDefinitions>
                            <telerik:GridViewTableDefinition />
                        </telerik:RadGridView.ChildTableDefinitions>
 
                        <!--sub agents : clients-->
                        <telerik:RadGridView.HierarchyChildTemplate>
                            <DataTemplate>
                                <telerik:RadGridView ItemsSource="{Binding Path=ClientAccounts}" AutoGenerateColumns="False" ShowGroupPanel="False" 
                                                     Visibility="{Binding Path=ClientAccounts.Count, Converter={StaticResource countToVisibleConverter}}">
                                    <telerik:RadGridView.Columns>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding AccountId}" Header="Account Id" Width="Auto" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="FirstName" Width="Auto"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="LastName" Width="Auto"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Volume}" Header="Volume" Width="Auto" DataFormatString="{}{0:N0}"/>
                                    </telerik:RadGridView.Columns>
                                </telerik:RadGridView>
                            </DataTemplate>
                        </telerik:RadGridView.HierarchyChildTemplate>
 
                    </telerik:RadGridView>
 
                    <!--clients-->
                    <telerik:RadGridView ItemsSource="{Binding Path=ClientAccounts}" AutoGenerateColumns="False" ShowGroupPanel="False" 
                                         Visibility="{Binding Path=ClientAccounts.Count, Converter={StaticResource countToVisibleConverter}}">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding AccountId}" Header="Account Id" Width="Auto" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="FirstName" Width="Auto"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="LastName" Width="Auto"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding Volume}" Header="Volume" Width="Auto" DataFormatString="{}{0:N0}"/>
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
 
                </StackPanel>
                                        
            </DataTemplate>
        </telerik:RadGridView.HierarchyChildTemplate>
 
    </telerik:RadGridView>

James
Top achievements
Rank 1
 answered on 16 Jan 2012
2 answers
411 views
I have a grid view that uses a datatemple for each row to edit data.  when I add a new row I want the cursor to be focused in the textbox in the datatemplate on the row details.  Nothing seems to work.  I have to tab to get to the textbox.  
<Window x:Class="GridviewDataTemplateFocusExample.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:GridviewDataTemplateFocusExample="clr-namespace:GridviewDataTemplateFocusExample" Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <DataTemplate x:Key="DetailView" >
            <GridviewDataTemplateFocusExample:DetailView />
        </DataTemplate>
    </Window.Resources>
        <Grid>
        <telerik:RadGridView HorizontalAlignment="Stretch"  Name="radGridView1" VerticalAlignment="Stretch"
                             ItemsSource="{Binding MyData}"
                             AutoGenerateColumns="False"
                             CanUserInsertRows="True"
                             RowIndicatorVisibility="Collapsed"
                             CanUserDeleteRows="False"
                             ShowInsertRow="True"
                             ShowGroupPanel="False"
                             IsSynchronizedWithCurrentItem="True"
                             AddingNewDataItem="radGridView1_AddingNewDataItem"
                             LoadingRowDetails="radGridView1_LoadingRowDetails"
                             RowDetailsVisibilityMode="Collapsed"
                             RowDetailsTemplate="{StaticResource DetailView}" >
            <telerik:RadGridView.Columns>
                <telerik:GridViewToggleRowDetailsColumn/>
                <telerik:GridViewDataColumn Header="Title" Width="250" DataMemberBinding="{Binding Name}" UniqueName="TitleColumn"/>
            </telerik:RadGridView.Columns>
 
        </telerik:RadGridView>
    </Grid>
</Window>

using System;
using System.Windows;
using System.Windows.Input;
using Telerik.Windows.Controls.GridView;
 
namespace GridviewDataTemplateFocusExample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.DataContext = new MainWindowVM();
            InitializeComponent();
        }
 
        private void radGridView1_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
        {
            (this.DataContext as MainWindowVM).AddNewDataObject();
            radGridView1.CommitEdit();
            var gridView = e.OwnerGridViewItemsControl;
            gridView.ScrollIntoViewAsync(gridView.Items[gridView.Items.Count - 1], //the row
                        gridView.Columns[1], //the column
                        new Action<FrameworkElement>((f) =>
                        {
                            var row = f as GridViewRow;
                            if (row != null)
                            {
                                row.IsSelected = true;
                                row.DetailsVisibility = Visibility.Visible;
                            }
                        }));
            e.Cancel = true;
        }
 
        private void radGridView1_LoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
        {
            Keyboard.Focus((e.DetailsElement as DetailView).tbxTitle);
 
        }
    }
}

using System.Collections.ObjectModel;
 
namespace GridviewDataTemplateFocusExample
{
    public class MainWindowVM
    {
        public ObservableCollection<DataObject> MyData { get; set; }
 
        public MainWindowVM()
        {
            MyData = new ObservableCollection<DataObject>();
            MyData.Add(new DataObject("Test 1"));
            MyData.Add(new DataObject("Test 2"));
            MyData.Add(new DataObject("Test 3"));
            MyData.Add(new DataObject("Test 4"));
            MyData.Add(new DataObject("Test 5"));
        }
 
        public void AddNewDataObject()
        {
            MyData.Add(new DataObject("Test ??????"));
        }
    }
 
    public class DataObject
    {
        public DataObject(string name)
        {
            Name = name;
        }
        public string Name { get; set; }
    }
}

<UserControl x:Class="GridviewDataTemplateFocusExample.DetailView"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid FocusManager.FocusedElement="{Binding ElementName=tbxTitle}"  FocusManager.IsFocusScope="True">
            <Border BorderThickness="2" Margin="3" BorderBrush="Black" CornerRadius="12" Padding="5" Background="Transparent" HorizontalAlignment="Stretch" >
                <telerik:RadTabControl Margin="2"  BackgroundVisibility="Hidden" HorizontalAlignment="Stretch" >
                    <telerik:RadTabItem Header="Details"  >
                        <Grid Width="Auto" HorizontalAlignment="Stretch" Background="Transparent" Margin="5" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
 
                            <TextBlock Text="Name: " Margin="0,5,0,5" FontWeight="Bold" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left"  Focusable="False"/>
                            <TextBox Name="tbxTitle" Text="{Binding Name}" Margin="0,5,0,5" Grid.Row="0" Grid.Column="1" 
                                 VerticalAlignment="Center" HorizontalAlignment="Stretch"  Focusable="true"
 
                                 />
 
                        </Grid>
                    </telerik:RadTabItem>
                    <telerik:RadTabItem Header="Page 2" >
  
                    </telerik:RadTabItem>
                    <telerik:RadTabItem Header="Page 3" >
                     </telerik:RadTabItem>
 
                </telerik:RadTabControl>
            </Border>
        </Grid>
    </Grid>
</UserControl>

Patricia
Top achievements
Rank 1
 answered on 16 Jan 2012
1 answer
135 views
Does Telerik have a control for WPF that's similar to the RadTitleBar for Winforms? I'd like to be able to have a theme-aware Title Bar for WPF.
Hristo
Telerik team
 answered on 16 Jan 2012
1 answer
120 views
Is it possible to make the GridView 100% 508 compliant? Does anyone have a specific solution?

The GridView I have is one that:

1) Data sources change. Same GridView is used to display many different collections of data depending on menu selection.

2) Selectable rows and cells. Double-click and a dialog shows to change values in the selected row.

3) Has sortable columns and the headers need to be readable by screen readers.

That's about all there is to it. I use JAWS to test the accessibility. I'm into UIAutomation. Any help is greatly appreciated. I don't want to have to replace the GridView with the standard WPF Data Grid.

Thank you.
Vlad
Telerik team
 answered on 16 Jan 2012
3 answers
114 views
Hi

I'm interested how can I find (and access in code) customized fields in a RadDataForm (edit) template.
When I edit a record Focus is not set on first field.
Can anyone give me a hint?

Thanks!
Ivan Ivanov
Telerik team
 answered on 16 Jan 2012
8 answers
537 views
Hi,

Continuing the same example as was in the previous query.

<telerik:RadTreeView HorizontalAlignment="Left"
                             x:Name="uxOrgTree"
                             Width="Auto"
                             Height="Auto"
                             d:LayoutOverrides="Height"  
                             VerticalAlignment="Top"
                             Margin="0,0,0,0"
                             SelectionMode="Single"
                             IsEditable="True"
                             ItemsSource="{Binding RootNodes}" >
            <telerik:RadTreeView.Resources>
                <HierarchicalDataTemplate DataType="{x:Type Entities:Node}" ItemsSource="{Binding Children}" >
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path= Name}"/>
                    </StackPanel>
                </HierarchicalDataTemplate>
            </telerik:RadTreeView.Resources>
      <telerik:RadTreeView.ItemContainerStyle>
                <Style TargetType="{x:Type telerik:RadTreeViewItem}">
                    <EventSetter Event="Edited" Handler="RadTreeViewItem_Edited" />
                 </Style>
            </telerik:RadTreeView.ItemContainerStyle>
        </telerik:RadTreeView>

I am trying to do something like styled as bold, in the code behind:

 private void ContextMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
               RadTreeViewItem currentItem = sender as RadTreeViewItem;
                if (currentItem != null)
                {
                    currentItem.ContextMenu.Tag = currentItem;
                }
      }

  private void MenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            MenuItem menu = sender as MenuItem;
            if (menu != null)
            {
                  ContextMenu contextMenu = this.FindResource("uxContextMenu") as ContextMenu;

                    Debug.Assert(contextMenu != null, "contextMenu == null", "null contextMenu");
                    RadTreeViewItem currentItem = contextMenu.Tag as RadTreeViewItem;
                   
                   //looking for 5th child of the currentItem, not sure how to get children if a treeview item.
                    currentItem.Children[5] as RadTreeViewItem;

                       
             }
        }

Thanks
Sonal
Hussein
Top achievements
Rank 1
 answered on 16 Jan 2012
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
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
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
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?