Telerik Forums
UI for WPF Forum
1 answer
154 views
Hello.

My WPF code has several nodes that are textually identical (including their contents) but refer to different data-contexts:

<telerik:RadTabControl IsSynchronizedWithCurrentItem="True">
    <telerik:RadTabControl.Resources>
        <system:String x:Key="Mandatory">* Mandatory field</system:String>
    </telerik:RadTabControl.Resources>
    <telerik:EventToCommandBehavior.EventBindings>
        <telerik:EventBinding Command="{Binding PreviewSelectionChanged}" EventName="PreviewSelectionChanged" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
    </telerik:EventToCommandBehavior.EventBindings>
    <telerik:RadTabItem Visibility="{Binding ProjectVisibility}">
        <telerik:RadTabItem.Header>
            <Label Content="_Projects" />
        </telerik:RadTabItem.Header>
        <DockPanel>
            <DockPanel.DataContext>
                <local:ProjectGridViewModel />
            </DockPanel.DataContext>
            <local:ButtonPanel DockPanel.Dock="Top"/>
            <TextBlock Text="{StaticResource Mandatory}" DockPanel.Dock="Bottom"/>
            <telerik:RadGridView ItemsSource="{Binding Path=ItemCollectionProperty, Mode=TwoWay}" SelectedItem="{Binding CurrentlySelectedItem, Mode=TwoWay, Converter={StaticResource ignoreNewItemPlaceHolderConverter}}" AutoGenerateColumns="False" CanUserDeleteRows="True" IsSynchronizedWithCurrentItem="True" ShowGroupPanel="False" DockPanel.Dock="Top" AlternateRowBackground="Beige" AlternationCount="2" SelectionMode="Extended">
                <telerik:EventToCommandBehavior.EventBindings>
                    <telerik:EventBinding Command="{Binding SelectionChangingCommand}" EventName="SelectionChanging" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                    <telerik:EventBinding Command="{Binding NewEventCommand}" EventName="AddingNewDataItem" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                    <telerik:EventBinding Command="{Binding DeleteEventCommand}" EventName="Deleting" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                </telerik:EventToCommandBehavior.EventBindings>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Name*" IsReadOnly="False" DataMemberBinding="{Binding ItemProperty.Name, Mode=TwoWay}">
                        <telerik:GridViewDataColumn.CellEditTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding ItemProperty.Name, Mode=TwoWay}" telerik:TextBoxBehavior.UpdateTextOnTextChanged="True" />
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellEditTemplate>
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="Description" IsReadOnly="False" DataMemberBinding="{Binding ItemProperty.Description, Mode=TwoWay}">
                        <telerik:GridViewDataColumn.CellEditTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding ItemProperty.Description, Mode=TwoWay}" telerik:TextBoxBehavior.UpdateTextOnTextChanged="True" />
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellEditTemplate>
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewComboBoxColumn Header="Coordinator*" ItemsSource="{Binding RelativeSource={RelativeSource Findancestor, AncestorType={x:Type Window}}, Path=DataContext.EmployeeCollection}" DataMemberBinding="{Binding Path=ItemProperty.coordinator}" DisplayMemberPath="ItemProperty.Name" SelectedValueMemberPath="ItemProperty.Name" IsVisible="{Binding CoordinatorColumnIsVisible}" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </DockPanel>
    </telerik:RadTabItem>
    <telerik:RadTabItem Visibility="{Binding EmployeeVisibility}">
        <telerik:RadTabItem.Header>
            <Label Content="_Employees" />
        </telerik:RadTabItem.Header>
        <DockPanel>
            <DockPanel.DataContext>
                <local:EmployeeGridViewModel />
            </DockPanel.DataContext>
            <local:ButtonPanel DockPanel.Dock="Top"/>
            <TextBlock Text="{StaticResource Mandatory}" DockPanel.Dock="Bottom"/>
            <telerik:RadGridView ItemsSource="{Binding Path=ItemCollectionProperty, Mode=TwoWay}" SelectedItem="{Binding CurrentlySelectedItem, Mode=TwoWay, Converter={StaticResource ignoreNewItemPlaceHolderConverter}}" CurrentItem="{Binding CurrentlySelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ignoreNewItemPlaceHolderConverter}}" AutoGenerateColumns="False" CanUserDeleteRows="True" IsSynchronizedWithCurrentItem="True" ShowGroupPanel="False" DockPanel.Dock="Top" AlternateRowBackground="Beige" AlternationCount="2" SelectionMode="Extended" VerticalContentAlignment="Stretch">
                <telerik:EventToCommandBehavior.EventBindings>
                    <telerik:EventBinding Command="{Binding SelectionChangingCommand}" EventName="SelectionChanging" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                    <telerik:EventBinding Command="{Binding NewEventCommand}" EventName="AddingNewDataItem" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                    <telerik:EventBinding Command="{Binding DeleteEventCommand}" EventName="Deleting" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                </telerik:EventToCommandBehavior.EventBindings>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Name*" IsReadOnly="False" DataMemberBinding="{Binding ItemProperty.Name, Mode=TwoWay}">
                        <telerik:GridViewDataColumn.CellEditTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding ItemProperty.Name, Mode=TwoWay}" telerik:TextBoxBehavior.UpdateTextOnTextChanged="True" />
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellEditTemplate>
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewComboBoxColumn Header="Location*" x:Name="Location" ItemsSource="{Binding RelativeSource={RelativeSource Findancestor, AncestorType={x:Type Window}}, Path=DataContext.ROLocationDbmCollectionProperty}" DataMemberBinding="{Binding Path=ItemProperty.Location}" DisplayMemberPath="ItemProperty.Name" SelectedValueMemberPath="ItemProperty.Name" />
                    <telerik:GridViewDataColumn Header="Recruitment Date*" DataMemberBinding="{Binding ItemProperty.RecruitmentDate}" DataFormatString="dd/MM/yyyy" Width="86" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </DockPanel>
    </telerik:RadTabItem>
    <telerik:RadTabItem Visibility="{Binding LocationVisibility}">
        <telerik:RadTabItem.Header>
            <Label Content="_Locations" />
        </telerik:RadTabItem.Header>
        <DockPanel>
            <DockPanel.DataContext>
                <local:LocationGridViewModel />
            </DockPanel.DataContext>
            <local:ButtonPanel DockPanel.Dock="Top"/>
            <TextBlock Text="{StaticResource Mandatory}" DockPanel.Dock="Bottom"/>
            <telerik:RadGridView ItemsSource="{Binding Path=ItemCollectionProperty, Mode=TwoWay}" SelectedItem="{Binding CurrentlySelectedItem, Mode=TwoWay, Converter={StaticResource ignoreNewItemPlaceHolderConverter}}" CurrentItem="{Binding CurrentlySelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ignoreNewItemPlaceHolderConverter}}" AutoGenerateColumns="False" CanUserDeleteRows="True" IsSynchronizedWithCurrentItem="True" ShowGroupPanel="False" DockPanel.Dock="Top" AlternateRowBackground="Beige" AlternationCount="2" SelectionMode="Extended" VerticalContentAlignment="Stretch">
                <telerik:EventToCommandBehavior.EventBindings>
                    <telerik:EventBinding Command="{Binding SelectionChangingCommand}" EventName="SelectionChanging" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                    <telerik:EventBinding Command="{Binding NewEventCommand}" EventName="AddingNewDataItem" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                    <telerik:EventBinding Command="{Binding DeleteEventCommand}" EventName="Deleting" RaiseOnHandledEvents="True" PassEventArgsToCommand="True" />
                </telerik:EventToCommandBehavior.EventBindings>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Name*" IsReadOnly="False" DataMemberBinding="{Binding ItemProperty.Name, Mode=TwoWay}">
                        <telerik:GridViewDataColumn.CellEditTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding ItemProperty.Name, Mode=TwoWay}" telerik:TextBoxBehavior.UpdateTextOnTextChanged="True" />
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellEditTemplate>
                    </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </DockPanel>
    </telerik:RadTabItem>
 
... several more similar-looking tab-items
 
</telerik:RadTabControl>


As you can see, the EventBindings of all RadGridView instances are textually identical, only under different data-contexts of each RadTabItem. This is code duplication, and I need to have code-reuse in order to solve it.
Is there a way to put all of those identical nodes in a single place and just make a reference to that place in each RadTabItem?
(If you also manage to do that for the identical repetitive appearances of ButtonPanel and Mandatory in each RadTabItem that would be great.)
Dimitrina
Telerik team
 answered on 22 Sep 2014
1 answer
145 views
I have exactly the same problem as described here

http://www.telerik.com/forums/suspend-sorting-during-paste

Basically I want to disable column sorting when users wants to paste their data into the grid
Just let the column unsorted and let user decide whether they want to sort again

I tried this on Pasting event of the grid, but it doesn't work
private void OnGridPasting(object sender, GridViewClipboardEventArgs e)
{
    ((RadGridView) sender).CurrentColumn.SortingState = SortingState.None;
}
It actually doing nothing, the column still get sorted on pasting, and I can see the sorting caret on the column header, which is weird !!

So I switched to PastingCellClipboardContent event and do this
private void OnPastingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e)
{
    e.Cell.Column.SortingState = SortingState.None;
}
The sorting caret on column header disappears, but as the data being modified, they still get sorted <-- I believe this is a bug

What else can I do to get my problem solved?

Thanks
Dimitrina
Telerik team
 answered on 22 Sep 2014
2 answers
342 views
Hi,

i use the RadPropertyGrid to show the properties of an ExpandoObject in unbound mode (AutoGenerateBindingPaths=false and AutoGeneratePropertyDefinitions=false). The PropertyDefinitions are created in code by my ViewModel.

In pseudo code my view model looks like:

dynamic model = new ExpandoObject();
model.MyProperty = 42;
 
PropertyDefinition property = new PropertyDefinition
{
     DisplayName = "MyProperty",
    Binding = new Binding("MyProperty")
    {
        Source = model,
        Mode = BindingMode.TwoWay
    }
};

On a first glance it seems to work. The property with the current value appears in the PropertyGrid.
But unfortunally the update is not working. When I change the value of the property in the PropertyGrid, the model is not updated. 

Is there a mistake on my side?


Best regards,
Thomas


Stefan
Top achievements
Rank 1
 answered on 22 Sep 2014
5 answers
188 views
Operating System: Windows 7
Telerik: 2012.2.912.40 (RadControls for WPF)

Issue: After adding RadPropertyGrid control in my WPF Class Library project and running the application,  I get "Could not load file or assembly 'Telerik.Windows.Controls.Data, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified."

Note- This works fine if the project type is of Windows application.  As mentioned above, does not work in  a class library project.
Dimitrina
Telerik team
 answered on 22 Sep 2014
16 answers
445 views
Hi,

I have html document(xyz.html),Under click event i want to open PDF file from html Document using Telerik.

Please let me know how can I proceed.

Regards,
Ranjith
Runjith
Top achievements
Rank 2
 answered on 22 Sep 2014
1 answer
340 views
I have been using Telerik GridView component (version 2014.2.729.45). I need to handle cell change event. Following events are fired consecutively:

1. Cell Validating
2. Cell Validated
3. Cell Edit Ended
4. Row Edit Ended
5. Cell Validating
6. Cell Validated
7. Cell Edit Ended
8. Row Edit Ended

Why these events are fired twice? Is this a bug?
Dimitrina
Telerik team
 answered on 19 Sep 2014
3 answers
223 views
We want to use RadMaskedDateTimeInput to let the user enter TimeSpans fo more than 24 hours.
For example 25 hours should be displayed and entered as

25:00:00  or   01:01:00:00 (one day and one hour)

using a "HH:mm:ss" or "dd:HH:mm:ss" mask does not work! 
Milena
Telerik team
 answered on 19 Sep 2014
12 answers
657 views
If I replace the RadAutoCompleteBox with a normal wpf textbox I can set focus in event OnLoaded with method myTextBox.Focus();
her is the code with the RadAutoCompleteBox that is not working:

<Window x:Class="Propertydesigner.Window1"
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
        xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
        Title="Window1" Height="300" Width="300" Loaded="Window1_OnLoaded" >
    <Grid>
        <telerik:RadBusyIndicator Grid.Row="1"  IsIndeterminate="True">
            <Grid HorizontalAlignment="Stretch" Margin="5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
 
                <StackPanel>
                    <TextBlock Text="Enter a document name" Margin="0 0 0 5"/>
                    <controls:RadAutoCompleteBox  x:Name="SearchForDocuments"
                         DisplayMemberPath ="Name"
                         SelectionMode="Single"
                         TextSearchMode="Contains"                   
                         HorizontalAlignment="Stretch"
                         Margin="0 0 0 3"/>
                </StackPanel>
 
                <StackPanel Grid.Row="2"
                    Orientation="Horizontal"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center"
                    Margin="0 10 0 0">
                    <telerik:RadButton Content="OK"  Width="70" Margin="0 0 10 0" />
                    <telerik:RadButton Content="Cancel" Width="70"/>
                </StackPanel>
            </Grid>
        </telerik:RadBusyIndicator>
    </Grid>
</Window>


  private void Window1_OnLoaded(object sender, RoutedEventArgs e)
        {
            SearchForDocuments.Focus();
        }


Nencho
Telerik team
 answered on 19 Sep 2014
5 answers
143 views
Hello,

I need to Populate current date in my telerik datepicker control as soon as i hit F3 key. How can i achieve this in wpf telerik datepicker?

Thanks,

Abdi
Kalin
Telerik team
 answered on 19 Sep 2014
0 answers
138 views
Hi Telerik Team,
I have a ContextMenu on a GridView where it will be opened on MouseLeftButtonClick, from here the Copy and Paste menu will invoke a copy and paste comman programmatically I've tried sample from the online documentation but I have no success. Any idea? 
Juzailie
Top achievements
Rank 2
 asked on 19 Sep 2014
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
ProgressBar
Sparkline
LayoutControl
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
Rating
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
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?