User Profile & Activity

Andry Handoko Soesilo Moderator
Posted: April 14, 2011 8:00 AM
Hi,

Hmm unfortunately we do not have this capability yet in our QueryDescriptor yet. Can you give me the GetData method with the linq query to the Entity object so that we can have better understanding whether we can support this in near future or not.

And btw what data service you are using DevForce or WCF RIA ?

Regards
Andry
Posted: January 14, 2011 4:10 AM

Hi Ross,

 

Your request to have property that populated with collection of drop items before its processed is actually a good idea to accomodate common practice in MVVM concept. Therefore the development team already put this request in high priority enhancement that you can get in the next hotfix.

 

So in a glance the new property that you can listen to is DropItems. This DropItems property will be populated right before the internal process to update the collection, and will be resetted after ward.

In your VIewModel, you need to have something like:

        public ObservableCollection<object> DropItems
        {
            get
            {
                return this._dropItems;
            }
            set
            {
                if (this._dropItems != value)
                {
                    this._dropItems = value;

                    if (this._dropItems != null)
                    {
                        Data data = this._dropItems[0] as Data;
                        data.Property1 = "new string";

                        // you can also clear the items if needed
                        // this._dropItems.Clear();
                    }

                    this.OnPropertyChanged("DropItems");
                }
            }
        }

Will notify you again when the hotfix is available.

Regards

Andry

Posted: January 11, 2011 10:35 PM

Drop event is considered interaction in View, so you need to attached Drop event handler at UXListBox and handle it in the View if you want to intercept the drop event.

 

You can declare the event handler directly in XAML.

<Intersoft:UXListBox x:Name="lbMyMemberships" Drop="lbMyMemberships_Drop">

 

And handle it at code behind.

using Intersoft.Client.UI.Controls.Interactivity;

private void lbMyMemberships_Drop(object sender, Intersoft.Client.UI.Controls.Interactivity.DragEventArgs e)
{
        UIElement sourceElement = e.GetSourceElement();
        IList<UIElement> dropElements = e.GetDropElements();

 // to do
}

Note that the e.GetSourceElement() , e.GetDropElements() and some other methods are extensions method. You need to import the Intersoft.Client.UI.Controls.Interactivity namespace.

Besides using direct event handler in XAML you can also handle it using EventManager. The Drop event and other related drag drop event is a routed event handler.

public MainPage()
{
    // Required to initialize variables
    InitializeComponent();

    ISEventManager.RegisterInstanceHandler(
        this.LayoutRoot, // any element in the routed path which applicable in your scenario
        DragDrop.DropEvent, // the routed event
        new Intersoft.Client.UI.Controls.Interactivity.DragEventHandler(lbMyMemberships_Drop), // the event handler
        true);
}

private void lbMyMemberships_Drop(object sender, Intersoft.Client.UI.Controls.Interactivity.DragEventArgs e)
{
        UIElement sourceElement = e.GetSourceElement();
        IList<UIElement> dropElements = e.GetDropElements();

 // to do
}

 

To learn more about handling routed events, see http://intersoftpt.com/Support/ClientUI/Docs/RoutedEventsOverview.html

 

 

 

Another perspective for this matter is intercepting the "Drop Event" in ViewModel. However this is limited to changes in data. For example if you drag an item from another UXListBox to this UXListBox, the itemsource collection will be changed. Therefore you can add CollectionChanged event handler at your ItemsSource collection in ViewModel and do additional tasks in that event handler.

 

Hope this helps

Regards

Andry

Posted: January 11, 2011 10:11 PM

Hi Ross,

This issue is a bug in Drag-Drop framework. Right-click should not initiate drag and this is the one causing the issue.

The hotfix is being prepared for this issue, you can get it on the latest hotfix release. Let me know if you encounter issue when right-click is not used.

 

About the UXListBox settings, you actually do not need to insert additional behavior.

 <i:Interaction.Behaviors>

    <Intersoft:DropTargetBehavior AllowDropItem="True"/>

</i:Interaction.Behaviors>

 

You just need the  AllowDropItem="True" property. Most of drag-drop related feature is configurable directly in UXListBox, so no need to insert additional behavior.

 

Regards

Andry

Hi Rick,

This feature has a bug in RC version and currently being fixed.

But to make sure that we can cover your scenario i'll explained how we can achive it and there some workaround you can try on with the RC version.

 

From my understanding it seems that you want to bind UXDesktopDock to an hierarchical object model and want to change the settings of each UXDesktopDockButton and its StackItems.

This is do-able but not through HierarhicalDataTemplate.

HierarchicalDataTemplate is used to define template in a uniform hierarhical structure such as MenuItem and TreeViewItem ( we don't have treeview component yet, but thats the idea)

 

For your scenario this is what you want to do.

First, prepare a data structure where the parent object contains collection property.
public class Item
{
     public ChildrenItemCollection Children
     public string DisplayText
     public ImageSource DisplayImage
}

public class ChildrenItem
{
     public string DisplayChildText
     public ImageSource DisplayChildImage
}

then do the binding as follows:

<Grid x:Name="LayoutRoot" 
DataContext="{Binding Source={StaticResource SampleDataSource}}"> <Intersoft:UXDesktopDock CollectionMemberPath="Children"
DisplayMemberPath="DisplayText"
ImageMemberPath="DisplayImage"
ItemsSource="{Binding Collection}"
ItemContainerStyle="{StaticResource UXDesktopDockButtonStyle1}"/> </Grid>

This will define the first level binding (Item lvl) to create the UXDockButton.

Note that there's definition call CollectionMemberPath, this define the path to look for SubItem Collection and since our data structure use Children as its property name we specify Children for CollectionMemberPath value.

The second steps is bind the second level (SubItem lvl) to do this you need to create a style for ItemContainerStyle.

ItemContainerStyle basically provide style across all item that belong to that specific control (in this case UXDesktopDock)

<Style x:Key="UXDesktopDockButtonStyle1" TargetType="Intersoft:UXDesktopDockButton">
    <Setter Property="ImageMemberPath" Value="DisplayChildImage"/>
    <Setter Property="StackMode" Value="GridStyle"/>	
</Style>

This will specify binding definition for ChildrenItem (StackItem)

Note that you can try on with ImageMemberPath in this level for RC version, the other properties such as DisplayMemberPath is not working but it will be in RTM version.

To workaround this you need to have the same property name for parent and child.

public class Item
{
     public ChildrenItemCollection Children
     public string DisplayText
     public ImageSource DisplayImage
}

public class ChildrenItem
{
     public string DisplayText
     public ImageSource DisplayImage
}

If you have the same property name DisplayText at parent and DisplayText at children.

You do not need to specify anything at child level, since the parent - child settings will be applied (meaning if the child property isn't changed it will use the parent one)

<Style x:Key="UXDesktopDockButtonStyle1" TargetType="Intersoft:UXDesktopDockButton">
    <Setter Property="FlippingEffectEnabled" Value="True"/>
    <Setter Property="StackMode" Value="GridStyle"/>	
</Style>

Hope this helps

Regards

Andry

All times are GMT -5. The time now is 12:20 AM.
Previous Next