Telerik Forums
UI for WPF Forum
4 answers
314 views
I'm trying to create a control with the same colors of RadGridView.
I tried to use the GridView_HeaderBackground as background, and GridView_GridLinesItemBorder as borderbrush. But when i changed my theme to Windows8, the Resource will not be found. Is there global definition for all themes? I really need that, in order to change my control with different themes automatically.
My code is like that:
<Border Background="{DynamicResource GridView_HeaderBackground}"
   BorderThickness="1"
   BorderBrush="{DynamicResource GridView_GridLinesItemBorder}">

Thanks a lot.
Yoan
Telerik team
 answered on 01 Apr 2014
3 answers
225 views
Hello everyone,

We were having issues with the 'ScrollItemIntoViewAsync' method.
When virtualization is turned on, none of the proposed solutions found on the internet worked (or not atleast a 100%).

E.g. when I'd randomly select an item from my entire collection (hierarchy depth could easily go down 30 levels or more) it wouldn't always correctly scroll to that row.

However, we managed to come up with a pretty straight forward solution which could be implemented by pretty much anyone. (And hopefully, internally by Telerik inside the grid controls as well)

The idea is that the root items in a hierarchical grid are always present, and we found that ScrollIntoViewAsync always worked when trying to scroll to root items.
So we'd first scroll to the root item, then to the next item inside the root item's collection and so on and so on untill we reached the actual item we were supposed to scroll to.

Prerequistes:

1.) The row item's view model must implement a specific interface (we called it IScrollableGridItem) that contains a "GetScrollList()" function which returns a list of objects that contains all the parents of that item and itself, in reversed order (eg the root item will be the first in the list and the actual item is the last)
2.) The row item's view model must have a reference to its parent item (to basically make the "GetScrollList()" work)
3.) Row height should be set on the grid (it doesn't seem to always work with no specified row height)

We made a custom behavior that allowed us to have a SelectedItem at any given time, regardless of the grid SelectionMode & SelectionUnit.


Inside this behavior, when the SelectedItem was being set via the ViewModel we added the following code:

001.private object actualScrollToItem = null;
002.private object currentScrollToItem = null;
003.private List<object> scrollItems = null;
004.private int scrollToItemAttemptCount = 0;
005. 
006.private void SelectedItemTargetUpdated(object sender, DataTransferEventArgs e)
007.{
008.    var item = GetValue(e.Property);
009. 
010.    /* SNIP IRRELEVANT CODE TO SCROLLING */
011.     
012.    actualScrollToItem = item;
013. 
014.    if (actualScrollToItem is IScrollableGridItem)
015.    {
016.        Console.WriteLine("-- BEGIN SCROLLING TO {0} --", actualScrollToItem.GetHashCode());
017. 
018.        var tmp = item as IScrollableGridItem;
019. 
020.        // Get a list of items to scroll to
021.        scrollItems = tmp.GetScrollList();
022. 
023.        // Start scrolling to the first item
024.        currentScrollToItem = scrollItems.First();
025. 
026.        GridControl.ScrollIntoViewAsync(currentScrollToItem, Scroll, ScrollFailed);
027. 
028.    }
029.    else
030.    {
031.        // Attempt is not IScrollable, attempt to scroll anyway
032.        currentScrollToItem = actualScrollToItem;
033.        Console.WriteLine("Item is not IScrollable");
034.        GridControl.ScrollIntoViewAsync(actualScrollToItem, Scroll, ScrollFailed);
035.    }
036.}
037. 
038.private void Scroll(FrameworkElement arg)
039.{
040.    Console.WriteLine("Succesfully scrolled to {0}", currentScrollToItem.GetHashCode());
041. 
042.    scrollToItemAttemptCount = 0;
043. 
044.    var row = arg as GridViewRow;
045. 
046.    if (actualScrollToItem == currentScrollToItem)
047.    {
048.        Console.WriteLine("Reached actual scroll item");
049.        Console.WriteLine("-- END SCROLLING TO {0} --", actualScrollToItem.GetHashCode());
050.        GridControl.ClearSelection();
051.        GridControl.SelectedItems.Add(currentScrollToItem);
052. 
053.        actualScrollToItem = null;
054.        currentScrollToItem = null;
055.        scrollItems = null;
056. 
057.        if (row != null)
058.        {
059.            row.IsCurrent = true;
060.            row.Focus();
061.            row.BringIntoView();
062.        }
063.    }
064.    else
065.    {
066.        if (row != null && row.IsExpandable)
067.        {
068.            row.IsExpanded = true;
069.        }
070. 
071.        var idx = scrollItems.IndexOf(currentScrollToItem);
072.        currentScrollToItem = scrollItems[idx + 1];
073. 
074.        GridControl.ScrollIntoViewAsync(currentScrollToItem, Scroll, ScrollFailed);
075.    }
076.     
077.}
078. 
079.private void ScrollFailed()
080.{
081.    scrollToItemAttemptCount++;
082. 
083.    Console.WriteLine("Failed to scroll to {0}. Already tried {1} times", currentScrollToItem.GetHashCode(), scrollToItemAttemptCount);
084. 
085.    if (currentScrollToItem == null)
086.    {
087.        Console.WriteLine("Stopped attempting to scroll because currentScrollToItem is NULL");
088.        scrollToItemAttemptCount = 0;
089.        return;
090.    }
091. 
092.    if (scrollToItemAttemptCount < 5)
093.    {
094.        GridControl.ScrollIntoViewAsync(currentScrollToItem, Scroll, ScrollFailed);
095.    }
096.    else
097.    {
098.        currentScrollToItem = null;
099.        actualScrollToItem = null;
100.        scrollToItemAttemptCount = 0;
101.    }
102.     
103.}

And for the sake of completeness, here's the code for the "GetParents()" implementation:

01.public List<object> GetParents()
02.{
03.    List<object> result = new List<object>();
04. 
05.    var tmp = Parent;
06. 
07.    // Get all my parents
08.    while (tmp != null)
09.    {
10.        result.Add(tmp);
11. 
12.        tmp = tmp.Parent;
13.    }
14. 
15.    // Add myself to the list
16.    result.Add(this);
17. 
18.    // We want the root item to be first in the list and myself last
19.    result.Reverse();
20. 
21.    return result;
22.}

Dimitrina
Telerik team
 answered on 01 Apr 2014
1 answer
264 views
Hi,

I my application is being written in a general MVVM architecture.  I'm wondering if there is any sort of way to be able to get rows to be "selected" without them actually being selected by the user.  For example I have something working using a style which binds to a property of my model and that works when the rows are manually selected via mouse clicks, however I cannot figure how to get rows to look visually selected when data is initially loaded.  Here is the Xaml I'm using to bind to the "IsSelected" property of collection of objects which are bound to my grid.

<UserControl.Resources>
     <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource {x:Type telerik:GridViewRow}}">
         <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
     </Style>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>

Any help on how to approach doing this would be greatly appreciated.
Dimitrina
Telerik team
 answered on 01 Apr 2014
10 answers
496 views
Hello,

I'm having problems trying to create panes, pane groups and split containers programmatically.
Is there some code sample that can show me how to programmatically add those objects?
I'm trying to dock some control to the left side and a couple documents.
It's very weird for example the property HasDocumentHost returns true event when DocumentHost property is null.

Could you help me on this?
Thanks in advance.
George
Telerik team
 answered on 01 Apr 2014
6 answers
94 views
Hi,
I have a WPF RadGridView and change the row background depend of 2 columns value:

<telerik:RadGridView.RowStyle>
                        <Style TargetType="telerik:GridViewRow">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <MultiBinding Converter="{StaticResource HashToBackgroundConverter}">
                                        <Binding Path="OldSha3Hash"/>
                                        <Binding Path="NewSha3Hash"/>
                                    </MultiBinding>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </telerik:RadGridView.RowStyle>

If both columns have equals value then Background is green, if not then is red.

How I can make a filter to show only green or red rows?

Best regards,
Saykor
Saykor
Top achievements
Rank 2
 answered on 31 Mar 2014
1 answer
229 views
With the following code I'm not getting the pdfviewer working:


<telerik:RadPdfViewer Name="PdfViewer" />


byte[] readAllBytes = File.ReadAllBytes(@"C:/Temp/Invoicer.Data/Rechnungsscans/K4967.pdf");
var memoryStream = new MemoryStream(readAllBytes);
this.PdfViewer.DocumentSource = new PdfDocumentSource(memoryStream, FormatProviderSettings.ReadAllAtOnce);


I'm using the version 2013.2.724.40. Passing the filename hard-coded in the xaml code also not works! Can someone give an hint??
Petya
Telerik team
 answered on 31 Mar 2014
1 answer
236 views
Is there a way to create a custom group header based on the group type?
Martin Ivanov
Telerik team
 answered on 31 Mar 2014
1 answer
169 views
Hello,

Is there a way to inherit the current font settings when pasting text into a RadRichTextBox that was copied from another RadRichTextBox?

If the destination has the text "original text" with Arial font and the source has the text "testing" with no font specified, copying and pasting after "original" should show "original testing text" with Arial font.

The following is what I'm trying:

XAML:
<t:RadRichTextBox Name="txt" Grid.Row="1" FontFamily="inherited" DocumentInheritsDefaultStyleSettings="True"/>
<TextBox Name="html" Grid.Row="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/>


Code Behind:

01.public MainWindow()
02.{
03.    InitializeComponent();
04. 
05.    txt.ChangeParagraphSpacingAfter(0);
06.    txt.DocumentContentChanged += TxtOnDocumentContentChanged;
07.}
08. 
09.private void TxtOnDocumentContentChanged(object sender, EventArgs eventArgs)
10.{
11.    UpdateHtml();
12.}
13. 
14.private void UpdateHtml()
15.{
16.    var settings = new HtmlExportSettings();
17.    settings.DocumentExportLevel = DocumentExportLevel.Fragment;
18.    settings.ExportStyleMetadata = false;
19.    settings.StylesExportMode = StylesExportMode.Inline;
20. 
21.    var converter = new HtmlFormatProvider();
22.    converter.ExportSettings = settings;
23.    html.Text = converter.Export(txt.Document);
24.}

The output shows the following:
<p class="Normal "><span style="font-family: 'Arial';">Original </span>testing<span style="font-family: 'Arial';"> text</span></p>

This causes testing to still be "inherited" since it is not inserted as a child of the span with "Original".  Is there any way I can do this or do I need to take over the Paste logic?


Thanks,
Wil
Petya
Telerik team
 answered on 31 Mar 2014
3 answers
109 views
Telerik,

                I have a problem trying to show the GridViewToggleButton in the second level of the Hierarchical Grid, the problem could have been solved if HasHierarchy had a setter. Since this is not achievable through code and because I was able to use WPF Inspector to change the value of HasHierarchy to make the GridViewToggleButton visible, I would like to request you to find me a workaround to solve this issue.

01.<telerikGrid:GridViewToggleButton MinHeight="24" MinWidth="24" IsHitTestVisible="{Binding IsExpandable, RelativeSource={RelativeSource TemplatedParent}}" Grid.Column="2" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" telerikGridView:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical">
02.    <telerikGrid:GridViewToggleButton.Opacity>
03.        <Binding Path="IsExpandable" RelativeSource="{RelativeSource TemplatedParent}">
04.            <Binding.Converter>
05.                <telerik:BooleanToOpacityConverter/>
06.            </Binding.Converter>
07.        </Binding>
08.    </telerikGrid:GridViewToggleButton.Opacity>
09.    <telerikGrid:GridViewToggleButton.Visibility>
10.        <Binding Path="HasHierarchy" RelativeSource="{RelativeSource TemplatedParent}">
11.            <Binding.Converter>
12.                <telerik:BooleanToVisibilityConverter/>
13.            </Binding.Converter>
14.        </Binding>
15.    </telerikGrid:GridViewToggleButton.Visibility>
16.</telerikGrid:GridViewToggleButton>
17.<Border Grid.Column="2" BorderBrush="#FFB3B3B3" BorderThickness="0,0,1,0" telerikGridView:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical">
18.    <Border.Visibility>
19.        <Binding Path="HasHierarchy" RelativeSource="{RelativeSource TemplatedParent}">
20.            <Binding.Converter>
21.                <telerik:BooleanToVisibilityConverter/>
22.            </Binding.Converter>
23.        </Binding>
24.    </Border.Visibility>
25.</Border>


Regards,
Jerric Lyns John

P.S. The first level Hierarchical Grid works just fine by showing the GridViewToggleButton but when it comes to the second level, it seems somehow internally HasHierarchy is set as False
Yoan
Telerik team
 answered on 31 Mar 2014
7 answers
941 views
Hello,
     I want to programmatically bold the text that appears in first column of my grid.
Thanks
Yoan
Telerik team
 answered on 31 Mar 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
Rating
SplashScreen
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
Jesse
Top achievements
Rank 2
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Jesse
Top achievements
Rank 2
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?