DevExpress TileLayoutControl - save and restore Tile's Visibility with XML file - devexpress

I use a TileLayoutControl. I use WriteToXML() and ReadFromXML() to save and restore the items position (the items are Tile). I would to be able to save the items Visibility too in the XML file to restore if a Tile is visible or not. How I can do that ?
Thank's for reply.

If you need to save/load custom properties, handle the LayoutControl.WriteElementToXML and LayoutControl.ReadElementFromXML events:
using DevExpress.Xpf.LayoutControl;
using DevExpress.Xpf.Core.Native;
void tileLayoutControl1_WriteElementToXML(object sender, LayoutControlWriteElementToXMLEventArgs e) {
if (typeof(Tile).IsAssignableFrom(e.Element.GetType()))
e.Element.WritePropertyToXML(e.Xml, UIElement.VisibilityProperty, "Visibility");
}
void tileLayoutControl1_ReadElementFromXML(object sender, LayoutControlReadElementFromXMLEventArgs e) {
if (typeof(Tile).IsAssignableFrom(e.Element.GetType()))
e.Element.ReadPropertyFromXML(e.Xml, UIElement.VisibilityProperty, "Visibility", typeof(Visibility));
}

Related

Xamarin forms SFListview multiselect issue

Iam using syncfusion SFListview in my xamarin forms app. I implemented multiselect of listview cell from https://help.syncfusion.com/xamarin/sflistview/selection?cs-save-lang=1&cs-lang=xaml.It works fine.But the problem iam facing is everytime we need to hold the itemcell for selection. Is it possible for multiselect that hold only for first cell and tap for all other cell?
Is it possible for multiselect that hold only for first cell and tap for all other cell?
Sure can do that.If you want multiselect items,I guess that next steps will do some tasks about multiselect items.The picture below may look like the one you want.
You can look at the content of this chapter in the share link, and the sample code it provides.
Solution One:(Generally acceptable)
If the project doesn't mind adding a control button outside, then this will be the quickest and easiest way.That is to add a ToolbarItems in the NavigationPage, use it to control whether you can click multiple selections without jumping to the next page.
Add ToolbarItems :
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="ToolbarItemsButton" Text="MultipleSelect" Clicked="Edit_Clicked"/>
</ContentPage.ToolbarItems>
<sync:SfListView x:Name="listView"
SelectionGesture="Hold"
SelectionMode="Multiple"
ItemTapped="ListView_ItemTapped"
SelectionBackgroundColor="Transparent"
IsStickyHeader="True" ItemSize="70">
...
In ContentPage ,add Flag to judge SelectionMode of ListView.
int flag = 0;
private void Edit_Clicked(object sender, EventArgs e)
{
if(0 == flag)
{
listView.SelectionGesture = TouchGesture.Tap;
ToolbarItemsButton.Text = "Done";
flag = 1;
}
else
{
ToolbarItemsButton.Text = "MultipleSelect";
listView.SelectionGesture = TouchGesture.Hold;
flag = 0;
}
}
Can judge when you can switch to the next page.
private void ListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
{
if(0 == flag)
{
Navigation.PushAsync(new ContentPage());
}
}
Solution Two:(Recommended)
SfListView has a method is ItemHolding.Not using another button also can exchange the SelectionMode.
Xaml code different is adding this method of SfListView.
<sync:SfListView x:Name="listView"
SelectionGesture="Hold"
SelectionMode="Multiple"
ItemTapped="ListView_ItemTapped"
SelectionBackgroundColor="Transparent"
ItemHolding="ListView_ItemHolding" // ItemHolding
IsStickyHeader="True" ItemSize="70">
When OnHolding can do something here:
private void ListView_ItemHolding(object sender, ItemHoldingEventArgs e)
{
if (0 == flag)
{
listView.SelectionGesture = TouchGesture.Tap;
ToolbarItemsButton.Text = "Done";
flag = 1;
}
else
{
listView.SelectionGesture = TouchGesture.Hold;
ToolbarItemsButton.Text = "MultipleSelect";
flag = 0;
}
}
Judge when you can switch to the next page.
private void ListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
{
if(0 == flag)
{
Navigation.PushAsync(new ContentPage());
}
}
Solution Three:(Not recommended here)
Generally, for the multiple selection of the cell of the listview, we will process the template of the custom cell, such as adding a button in the template. When clicking, the item can be marked as selected, and the UI of the item can also be customized as The style when selected.

How to configure ExpressionTextBox bindings / OwnerActivity when used in a dialog?

Our group is working on a Custom Activity Designer around our Email activity. It's a pretty straight forward designer, allow the user to enter settings / creds, but instead of cluttering the activity designer with all the settable options, we thought about putting some settings in a dialog window. (Which opens when you click the button beside the server address box).
Some of our email activity properties are InArguments so we are trying to make use of the ExpressionTextBox to display these values without much luck. The main problem is we aren't sure how to properly set up the binding and the OwnerActivity on the ExpressionTextBox. In the Activity Designer's xaml this is simply done by setting Expression=ModelItem.Property using a converter for the InArgument and setting the OwnerActivity=ModelItem, like this:
<view:ExpressionTextBox HintText="Enter a VB Expression" Expression="{Binding ModelItem.ServerAddress, ConverterParameter=In, Converter={StaticResource ArgumentToExpressionConverter}, Mode=TwoWay}" ExpressionType="{x:Type system:String}" OwnerActivity="{Binding ModelItem}" Margin="2" MaxLines="1" />
If anyone has any ideas on how we could accomplish this in a dialog, please advise.
Well, this is more a WPF\MVVM question than WF4, really.
When developing custom activities designers you just have to keep one thing in mind: any change made on designer\dialog should be reflected on ModelItem. Either through XAML binding expressions or through code on ModelItem.Properties property.
Now, when and how you do it, there are several answers to that but that's really an implementation detail and depends on how you want to do it.
Lets assume you're showing the dialog on button-beside-the-server-address-box click. And lets also assume you've access to dialog textboxes through their name. At that point, you've access to ModelItem so just set its properties as needed:
private void ButtonNextToServerAddressBox_OnClick(object sender, RoutedEventArgs e)
{
var dialog = new ServerAddressEditor();
var result = dialog.ShowDialog();
if (result ?? false)
{
ModelItem.Properties["Server"].SetValue(new InArgument<string>(dialog.ServerTextBox.Text));
ModelItem.Properties["Port"].SetValue(new InArgument<string>(dialog.PortTextBox.Text));
// ... set all other properties
}
}
Now, if you are using any other pattern, or you want pure MVVM, it can be a little more tricky because of how ModelItem works. But this is a totally fine approach.
I resolved this by creating a property in the dialog's ViewModel to hold the Activity Designer's ModelItem.
public ModelItem OwnerActivity {
get { return _OwnerActivity; }
set { _OwnerActivity = value; }
}
vm.OwnerActivity = this.DataContext.ModelItem;
I then set the Xaml for the Expression Text Box in my dialog to binding to this:
<view:ExpressionTextBox HintText="Enter a VB Expression" Expression="
{Binding Path=OwnerActivity.ServerAddress, ConverterParameter=In, Converter=
{StaticResource ArgumentToExpressionConverter}, Mode=TwoWay}" ExpressionType="
{x:Type system:String}" OwnerActivity="{Binding OwnerActivity}" Margin="2"
MaxLines="1" />
Because I'm now binding directly to the ModelItem from the Activity Designer, any change made to the ModelItem property from the dialog is ALWAYS committed, even if you choose to Cancel from the dialog. To wire up the Ok/Cancel buttons so they work accordingly, I did the following in the dialog:
// declare a ModelEditingScope to make changes transactional
private ModelEditingScope _editScope;
// add this to the constructor of the dialog to begin transactional edits on the ModelItem
_editScope = editorViewModel.OwnerActivity.BeginEdit();
// ok & cancel button click event to commit or revert the changes.
private void OK_Click(object sender, RoutedEventArgs e)
{
_editScope.Complete();
this.DialogResult = DialogResult.OK;
this.Close();
}
private void Cancel_Click(object sender, RoutedEventArgs e)
{
_editScope.Revert();
this.DialogResult = DialogResult.Cancel;
this.Close()
}

Silverlight toolkit : How to read seleted value of a data point on Bubble Chart

I have created a Bubble chart using silverlight tookit as follows :
<charting:Chart Title="Bubble Chart"
LegendTitle="Legend"
Name="chart1" Margin="0,0,0,42"
HorizontalAlignment="Left" Width="568">
<charting:Chart.Series>
<charting:BubbleSeries Title="Pollutant A" IsSelectionEnabled="True"
ItemsSource="{Binding Pollution}"
IndependentValuePath="AQI"
DependentValuePath="Level"
SelectionChanged="ChangeSomething"
SizeValuePath="size1" >
</charting:BubbleSeries>
</charting:Chart>
And my xaml.cs defines the handler like this :
private void ChangeSomething(object sender, SelectionChangedEventArgs e){
Text1.text="selection changed"
// Here I want to show the value of the bubble selected
}
Can someone Please tell me How to do that ? thanks :)
The SelectionChangedEventArgs parameter will contain a property called AddedItems, this is a list of the items for the ItemsSource that have been added to the selected items during this change. Most of the time there is only one, its the item that was just selected.
For the sake of example I'll event a type name for the objects returned by your Pollution property in your model. I'll give the type name PollutionSample (of course I'm just guessing here).
So you would access the selected PollutionSample like this:-
private void ChangeSomething(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
PollutionSample ps = e.AddedItems[0] as PollutionSample;
if (ps != null)
{
// Do something with sample
}
}
}

How to expand .NET TreeView node by clicking its text instead of +/-

I've been using hardcoded hyperlinks for my web app navigation, but the app has grown since and managing it is becoming a real pain. I've decided to replace what I have with the TreeView control, however I want to make several changes to the way it looks.
Is there any property that needs to be set, that would allow user to expand the TreeView node by clicking its text instead of +/- ?
I've already set ShowExpandColapse to 'false'.
I want my final result to end up as something similar to the TreeView on the left of the MSDN site.
Could anyone point me at the right direction please?
Set TreeNode.SelectAction to either Expand, or SelectExpand.
you can use xml data source or direct binding from db to treview
in the TreeView DataBound event we can write d recursive function as below to fetch each node and assign expand action to them.
protected void TreeView1_DataBound(object sender, EventArgs e)
{
foreach (TreeNode node in TreeView1.Nodes)
{
node.SelectAction = TreeNodeSelectAction.Expand;
PrintNodesRecursive(node);
}
}
public void PrintNodesRecursive(TreeNode oParentNode)
{
// Start recursion on all subnodes.
foreach(TreeNode oSubNode in oParentNode.ChildNodes)
{
oSubNode.SelectAction = TreeNodeSelectAction.Expand;
PrintNodesRecursive(oSubNode);
}
}
I think you just have to do this in code: handle the Click event, determine the currently-selected tree node, and toggle its Expanded property (I think that's what it's called here).
You can do this only this way! http://geekswithblogs.net/rajiv/archive/2006/03/16/72575.aspx
With respect,
Alexander

'Databinding complete' event for Silverlight 4.0 DataGrid?

I have a DataGrid that I have bound to a property:
<cd:DataGrid
Name="myDataGrid"
ItemsSource="{Binding Mode=OneWay,Path=Thingies}"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
...
When the Thingies property changes, once all rows in the DataGrid have been populated with the new contents of Thingies, I want the DataGrid to scroll to the bottom row.
In WinForms, I would have done this by subscribing to the DataBindingComplete event. MSDN Forums contains several suggestions on how to do this with Silverlight 4.0 but they range from completely evil to just plain fugly:
start a 100ms timer on load, and scroll when it elapses
count rows as they're added, and scroll to the bottom when the number of added rows equals the number of entities in the data source
Is there an idiomatic, elegant way of doing what I want in Silverlight 4.0?
I stumbled upon this while searching for a resolution to the same problem. I was finding that when I attempted to scroll the selected item into view after filter and sort changes that I frequently received a run time error (index out of bounds). I knew instinctively that this was because the grid was not populated at that particular moment.
Aaron's suggestion worked for me. When the grid is defined, I add an event listener:
_TheGrid.LayoutUpdated += (sender, args) => TheGrid.ScrollIntoView(TheGrid.SelectedItem, TheGrid.CurrentColumn);
This solved my problem, and seems to silently exit when the parameters are null, too.
Why not derive from DataGrid and simply create your own ItemsSourceChanged event?
public class DataGridExtended : DataGrid
{
public delegate void ItemsSourceChangedHandler(object sender, EventArgs e);
public event ItemsSourceChangedHandler ItemSourceChanged;
public new System.Collections.IEnumerable ItemsSource
{
get { return base.ItemsSource; }
set
{
base.ItemsSource = value;
EventArgs e = new EventArgs();
OnItemsSourceChanged(e);
}
}
protected virtual void OnItemsSourceChanged(EventArgs e)
{
if (ItemSourceChanged != null)
ItemSourceChanged(this, e);
}
}
Use the ScrollIntoView method for achieving this.
myDataGrid.ItemSource = Thingies;
myDataGrid.UpdateLayout();
myDataGrid.ScrollIntoView(MyObservableCollection[MyObservableCollection.Count - 1], myDataGrid.Columns[1]);
You don't need to have any special event for this.
I think the nice way to do it, in xaml, is to have the binding NotifyOnTargetUpdated=true, and then you can hook the TargetUpdated to any event of your choice.
<ThisControl BindedProperty="{Binding xxx, NotifyOnTargetUpdated=true}"
TargetUpdated="BindingEndedHandler">

Resources