Home Forums WPF controls Xceed DataGrid for WPF A few CardView questions

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24528 |

    Hello,
    I spent last 3 days searching for answers on how to customize your DataGrid the way I want it too look and behave, but after googling and reading the forums I still have few unanswered questions.
    Also, if it’s possible please provide short samples with your answers because I’m not very familiar with XAML yet.

    1) How can one (either by using custom themes, styling or templating) change color and size of scrollbars? The only answer for this question I found on the forums says that its not possible, but default themes has different scrollbars colors so I think it should be doable…

    2) Is it possible to explicity set the number of cards displayed per column (with vertical orientation) or row (with horizontal)?

    3) When I choose item using mouse then CurrentItemGlyph is shown and selection color changes, but when I start using keyboard arrows to navigate through the grid there is also dotted board visable within CurrentItem’s Card (…and I don’t even know how to name it). Is it possible to disable this behaviour?

    Currently I’m using the workaround on the PreviewKeyDown event:

    _DataGrid.SelectedIndex = …;
    _DataGrid.BringItemIntoView(_DataGrid.Items[_DataGrid.SelectedIndex]);

    …but I guess that using _DataGrid.CurrentItem = … would be the best way to select a row.

    4) How can one access VirtualizingCardPanel’s methods (like LineUp, LineDown)?

    I created VirtualizingCardPanel using this XAML code:

    <xcdg:DataGridControl Name=”_DataGrid”>
    <xcdg:DataGridControl.ItemsPanel>
    <ItemsPanelTemplate>
    <xcdg:VirtualizingCardPanel Orientation=”Horizontal” x:Name=”_Virtual”/>
    </ItemsPanelTemplate>
    </xcdg:DataGridControl.ItemsPanel>
    <xcdg:DataGridControl.View>
    <xcdg:CardView/>
    </xcdg:DataGridControl.View>
    </xcdg:DataGridControl>

    …but I can’t figure out (and forums and google aren’t really helpful here) how can I invoke its methods?
    Please note that there is no object named “_Virtual” which is visable by VS.

    5) Is it possible to somehow use Orientation=”Horizontal” without using VirtualizingCardPanel? I would really like to use the CardWidth property.

    6) Is CustomViews sample broken?

    Employees data table is populated with data from Northwind database but grid is always empty.
    Also, while running application and switching to TableView, output window shows those errors:

    System.Windows.Data Error: 35 : BindingExpression path error: ‘CardWidth’ property not found on ‘object’ ”TableView’ (HashCode=66622070)’. BindingExpression:Path=(0).ViewBindingContext.CardWidth; DataItem=’VirtualizingCardPanel’ (Name=”); target element is ‘VirtualizingCardPanel’ (Name=”); target property is ‘FixedSize’ (type ‘Double’)
    System.Windows.Data Error: 35 : BindingExpression path error: ‘AllowCardResize’ property not found on ‘object’ ”TableView’ (HashCode=66622070)’. BindingExpression:Path=(0).ViewBindingContext.AllowCardResize; DataItem=’VirtualizingCardPanel’ (Name=”); target element is ‘VirtualizingCardPanel’ (Name=”); target property is ‘AllowCardResize’ (type ‘Boolean’)
    System.Windows.Data Error: 35 : BindingExpression path error: ‘SeparatorLinePen’ property not found on ‘object’ ”TableView’ (HashCode=66622070)’. BindingExpression:Path=(0).ViewBindingContext.SeparatorLinePen; DataItem=’VirtualizingCardPanel’ (Name=”); target element is ‘VirtualizingCardPanel’ (Name=”); target property is ‘SeparatorLinePen’ (type ‘Pen’)

    …switching back to CardView shows those:

    System.Windows.Data Error: 35 : BindingExpression path error: ‘HorizontalGridLineBrush’ property not found on ‘object’ ”CompactCardView’ (HashCode=24089510)’. BindingExpression:Path=(0).ViewBindingContext.HorizontalGridLineBrush; DataItem=’VirtualizingStackPanel’ (Name=”); target element is ‘VirtualizingStackPanel’ (Name=”); target property is ‘ContentBorderBrush’ (type ‘Brush’)
    System.Windows.Data Error: 35 : BindingExpression path error: ‘HorizontalGridLineThickness’ property not found on ‘object’ ”CompactCardView’ (HashCode=24089510)’. BindingExpression:Path=(0).ViewBindingContext.HorizontalGridLineThickness; DataItem=’VirtualizingStackPanel’ (Name=”); target element is ‘VirtualizingStackPanel’ (Name=”); target property is ‘ContentBorderThickness’ (type ‘Thickness’)
    System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey=’defaultTheme’

    …any ideas what might be broken?

    Please note that I’m using Xceed DataGrid for WPF 1.2 (3.1.7376.15421) with Free key and Visual Studio 2008 Beta 2.

    Imported from legacy forums. Posted by Piotr (had 1077 views)

    Xceed Support
    Member
    Post count: 5658

    <b> #1: </b>

    I remember something like this… Let me check things in detail and I’ll get back to you!

    <b>#2:</b>
    There is no explicit options to limit the number of cards. If your DataGridControl has a fixed size, you could alternately set the “Height” of all DataRow’s so that only the specified number of rows fit in a column ( this can be done by creating an implicit style on DataRow ).

    <code>
    <Window.Resources>
    <Style TargetType=”{x:Type xcdg:DataRow}”>
    <Setter Property=”Height” Value=”45″ />
    </Style>
    </Window.Resources>
    </code>

    <b>#3: </b>

    The simplest way to remove the “dotted border” is to ensure that the FocusVisualStyle property of the elements focused are set to “null”.

    For the cell, you can do so by creating an implicit style for the DataCell class.

    <code>
    <Window.Resources>
    <Style TargetType=”{x:Type xcdg:DataCell}”>
    <Setter Property=”FocusVisualStyle” Value=”{x:Null}” />
    </Style>
    </Window.Resources>
    </code>

    For the row, you will need to “redo” the ControlTemplate and ensure the “PART_RowFocusRoot” and/or “PART_CellsHost” elements of the template have their FocusVisualStyle set to null.

    <code>
    <Window.Resources>
    <ControlTemplate x:Key=”myModifiedTemplate” TargetType=”{x:Type xcdg:DataRow”}>

    </ControlTemplate>

    <Style TargetType=”{x:Type xcdg:DataRow}”>
    <Setter Property=”Template” Value=”{StaticResource myModifiedTemplate}” />
    </Style>
    </Window.Resources>
    </code>

    While creating your own data row template might sound difficult, we have provided you with all our “system” theme styles and templates in the “themes” subfolder of the Xceed DataGrid for WPF installation folder (so you can start from them, as a reference).

    <b>#4: </b>

    To access navigation function, I suggest going through the ScrollViewer for the DataGridControl instead of the ItemsPanel.

    This can be done this way:

    ScrollViewer myScrollViewer = myDataGridControl.Template.FindName( “PART_ScrollViewer”, myDataGridControl) as ScrollViewer;

    Otherwise, if you truly need to access some properties and functions from the ItemsPanel, what I can suggest is setting a “loaded” handler on the panel and storing the sender when the handler executes.

    <code>
    <ItemsPanel>
    <ItemsPanelTemplate>
    <StackPanel Loaded=”myHandler” />
    </ItemsPanelTemplate>
    </ItemsPanel>
    </code>

    <b>#5: </b>

    I’m not sure I understand the question. You can use “any” Panel derived class in the ItemsPanelTemplate…

    Please note however, that to preserve all the UI virtualization, grouping, headers/footer and additional performance improvements, you will need to provide a DataGridVirtualizingPanel.

    <b>#6:</b>

    “Employees data table is populated with data from Northwind database but grid is always empty.”

    Please refer to the <a href=”http://forums.xceed.com/forums/ShowPost.aspx?PostID=6869″>FAQ sticky post</a> concerning VS2008 compatibility.

    Concerning the trace output errors:

    We are aware of these errors, they are caused by the fact the grid elements “templates” currently in use by the grid elements are bound to properties of the “old” view until the new templates (for the new view) are applied.

    The errors are not indicating anything wrong and should not be considered a “problem”.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 3340 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.