This is a migrated thread and some comments may be shown as answers.

Gridview not locating styles in Demo Samples

1 Answer 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jared Bossart
Top achievements
Rank 1
Jared Bossart asked on 24 Sep 2011, 01:13 AM
In short I've been unable to modify the style settings for the gridview row reorder example.
The demo example can not locate the style settings. I've been messing around and narrowed it down that this line of code does not expose the gridview namespace because the RowStyle property would state "Cannot resolve path."

Question:
How would I be able to modify the top and bottom lines of the DraggedTemplate?
From:
Line 1: Customer: Bob (Orange background)
Line 2: Drop after Customer: James

To:
Line1: Method 21 (Blue Background)
Line2: Drop after Sequence Run 30


I included this to expose the GridViewRow

xmlns:gd="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"

For x:Key="DraggedRowStyle

<Grid.Resources>
            <Style TargetType="gd:GridViewRow" x:Key="DraggedRowStyle">
                <Setter Property="dragAndDrop:RadDragAndDropManager.AllowDrag" Value="True" />
            </Style>
            <Style TargetType="treeView:TreeViewDragCue" x:Key="CueStyle">
                <Setter Property="DragTooltipVisibility" Value="Collapsed"/>
            </Style>
            <DataTemplate x:Key="DraggedItemTemplate">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Sender}" FontWeight="Bold" />
                    <TextBlock Text=", (" Foreground="Gray" />
                    <TextBlock Text="{Binding Subject}" Foreground="Gray" />
                    <TextBlock Text=")" Foreground="Gray" />
                </StackPanel>
            </DataTemplate>
            <LinearGradientBrush x:Key="DropPossibleBackground" StartPoint="0 0" EndPoint="0 1">
                <GradientStop Offset="0" Color="White" />
                <GradientStop Offset="1" Color="#FFE699" />
            </LinearGradientBrush>
            <DataTemplate x:Key="testTemplate1">
                <Border Width="50" Height="50" Background="Red">
                </Border>
            </DataTemplate>
            <DataTemplate x:Key="testTemplate2">
                <Border Width="50" Height="50" Background="Green">
                </Border>
            </DataTemplate>
        </Grid.Resources>

Here is my gridview

<telerik:RadGridView HorizontalAlignment="Stretch" Name="RadGridView1"
                     VerticalAlignment="Stretch" AutoGenerateColumns="False"
                     CanUserFreezeColumns="False" CanUserReorderColumns="False"
                     ShowColumnHeaders="True" ShowGroupPanel="False" ShowInsertRow="True"
                     DataContext="{Binding Source={StaticResource SequenceCollectionData}}"
                     dragAndDrop:RadDragAndDropManager.AllowDrop="True" RowStyle="{StaticResource DraggedRowStyle}">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Sample Name" UniqueName="gvcSample" IsGroupable="False"
                                    IsReorderable="False" DataMemberBinding="{Binding Path=SampleName}" />
        <telerik:GridViewDataColumn Header="ID" UniqueName="gvcGuidID" IsGroupable="False"
                                    IsReorderable="False" DataMemberBinding="{Binding Path=GuidID}"
                                    IsReadOnly="True"/>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

Restating Question: How would I be able to modify the top and bottom lines of the DraggedTemplate?
From:
Line 1: Customer: Bob
Line 2: Drop after Customer: James

To:
Line1: Method 21
Line2: Drop after Sequence Run 30

Thank you,

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 27 Sep 2011, 03:18 PM
Hi Jared Bossart,

Here I am pasting the answer that I have posted in your other thread.

I will start from the explanation about 'Line 2' and then continue with the one for 'Line 1'. For 'Line 2' you need to set the 'DragCueTooltipContentTemplate'.

In the demo sample inside "RowReorderBehavior.cs" you will find the "OnRowDragOver" method. You will need to change it so that it sets the appropriate value for the DragTooltipContent.

You could just set the entire Item(and specify which property of the item  to be shown using a style) (please see the line in red):

private void OnRowDragOver(objectsender, Telerik.Windows.DragDrop.DragEventArgs e)         { ...
   
if(e.Effects == DragDropEffects.All)
            {
                DropPosition fff = this.GetDropPositionFromPoint(e.GetPosition(Application.Current.RootVisual), row);
    
                cue.DragActionContent = String.Format("Drop {0}", Enum.GetName(typeof(DropPosition), fff));
                cue.DragTooltipContent = ((SilverlightApplication25.User)(currentDropItem));
                cue.IsDropPossible = true;
            }
}

Then using styles, you could change any property of the 'TreeListViewDragCue'.
If you take a look at the snippet bellow, you will see how I specify the Content and the Background color of 'Line 1'.

Then I set a template that specifies what property to be shown in the TooltipContentTemplate ('Line 2').

<telerik:RadGridViewx:Name="DestinationGrid"  rowReorder:RowReorderBehavior.IsEnabled="True">
          <rowReorder:RowReorderBehavior.DragCueStyle>
<!--Line 1 -->
              <StyleTargetType="telerik:TreeListViewDragCue">
<SetterProperty="DisplayMemberPathValue="LastLoginDate"></Setter>
<SetterProperty="BackgroundValue="Aqua"></Setter>
              </Style>
          </rowReorder:RowReorderBehavior.DragCueStyle>
<!-- Line 2 -->
          <rowReorder:RowReorderBehavior.DragCueTooltipContentTemplate>
              <DataTemplate>
                  <StackPanelOrientation="Horizontal">
                      <TextBlockMargin="5 0 0 0"Text="{Binding Approved}"></TextBlock>
                  </StackPanel>
              </DataTemplate>
          </rowReorder:RowReorderBehavior.DragCueTooltipContentTemplate>
      </telerik:RadGridView>

I hope that this explanation will help you to implement your case.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Jared Bossart
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or