I converted my gridview to tile view and I added some format rules. When I run my project, format rules doesn't work.I'm sure my rule is correct. What should I do ?
As I discovered till now, To customize the tile conditionally then you should handle TileView.ItemCustomize Event.
Refer this: Tile View
The TileView.ItemCustomize event fires for each tile before this tile
is displayed. When handling this event, you can read its e.Item
parameter to access the completely generated, ready to be displayed
tile item. Afterwards, you can apply required changes. For instance,
apply a different background color or access the TileItem.Elements
collection to modify specific elements.
All TileViewItemElements within the view can be customized by accessing appearance settings available through the TileView.AppearanceItem property. At the same time, each individual element has its own appearance settings that override this global appearance. To access these appearances, use the TileItemElement.Appearance property.
example:
private void tileView1_ItemCustomize(object sender, DevExpress.XtraGrid.Views.Tile.TileViewItemCustomizeEventArgs e) {
e.Item.Elements[6].Text = String.Format("${0}M", ((Decimal)(Int32)tileView1.GetRowCellValue(e.RowHandle, colPrice) / 1000000).ToString("0.0"));
if ((bool)tileView1.GetRowCellValue(e.RowHandle, colSold) == true) {
e.Item.Elements[1].Image = global::TileViewHomes.Properties.Resources.gray_element;
e.Item.Elements[6].Text = "SOLD";
//Changes background colour of non selected tileitem
e.Item.AppearanceItem.Normal.BackColor = Color.Red;
}
}
References:
tileView_ItemCustomize is not updating until resize
Related
My main page uses a TabbedPage to group existing news into different lists. The tabs aren't fixed; they're built from a data binding operations against a collection that's retried through a web service call.
I'd like to persist the selected tab across activity restarts, but it seems like I'm missing something. Since there's no selected tab property (which can be set through data binding), I've tried to handle the PageChanged and the CurrentPageChangedCommand events. I'm using the PageChanged to set the selected tab to the previous selected tab and the CurrentPageChangedCommand is being used to update the persisted selected tab (I'm using the Application.Properties to make sure the selected tab survives app restarts).
Unfortunately, the events generated by the tab will always set tab 0 as the selected tab! Here's what I'm seeing (let's assume that my app was killed white tab 3 was active):
When data is bound to the TabbedPage.ItemsSource property, the tab will automatically fire the CurrentPageChangedCommand, passing the first tab (tab at position 0).
My code handles the event and updates the current persisted selected tab by changing the selected tab in the Properties dictionary. So now, instead of 3 (which was the value persisted when my app was killed), it will have 0.
Then the tab will fire the PagesChanged
When my code handles this event, it will try to update the selected tab. However, when it access the selected tab from the Properties dictionary, it will get the default tab (0) and not 3. This happens because the CurrentPageChangedCommand was fired before the PagesChanged event (step 2), completely overriding the previously persisted tab index.
This default behaviour will also give a bad user experience when the user refreshes the current list (pull to refresh) because he always ends up seeing tab 0 list.
So, any clues on how to solve this? How have you guys solved this?
Thanks.
It seems it can't be achieved using MVVM as CurrentPage is not a bindable property and CurrentPageChanged is an event.
However, there's no need to handle the PagesChanged event. You could record the index in the changed event like:
private void MyTabbedPage_CurrentPageChanged(object sender, EventArgs e)
{
Application.Current.Properties["index"] = this.Children.IndexOf(CurrentPage);
Application.Current.SavePropertiesAsync();
}
Then you could set your tabbed page's current page after you have loaded all the tabs:
object index;
Application.Current.Properties.TryGetValue("index", out index);
if (index != null)
{
CurrentPage = Children[int.Parse(index.ToString())];
}
// Subscribe the event
CurrentPageChanged += MyTabbedPage_CurrentPageChanged;
I placed the code above in the custom tabbed page's constructor and it could change the selected tab at initial time.
Update:
If you want to change the tabbed page's children dynamically, you could define a property to avoid the event being fired when you change the children:
bool shouldChangeIndex = true;
private void MyTabbedPage_CurrentPageChanged(object sender, EventArgs e)
{
if (shouldChangeIndex)
{
var index = this.Children.IndexOf(CurrentPage);
Application.Current.Properties["index"] = index;
Application.Current.SavePropertiesAsync();
}
}
// Simulate the adjusting
shouldChangeIndex = false;
Children.Clear();
Children.Add(new MainPage());
Children.Add(new SecondPage());
shouldChangeIndex = true;
object index;
Application.Current.Properties.TryGetValue("index", out index);
if (index != null)
{
CurrentPage = Children[int.Parse(index.ToString())];
}
Unfortunately, I had to abandon the MVVM approach...In the end, I had to resort to code and a couple of flags to control when the generated tab events should be handled.
I'm hoping there is a pattern for verifying when a property is set for a custom control in asp.net.
Considering that there is a page life cycle, we keep having issues where the control can get into an invalid state. The best thing we can do is raise an exception with an instructional message for things like, setting values selected before adding data.
Please note, ideally the component wouldn't rely on things like ordering of when a property is set. Unfortunately I can only move the company to better practices one step at a time. There are too many components to re-write from scratch and is an unrealistic expectation.
That said, here's an example.
We have two properties. SelectedValues which will set the values that match a comma separated list and InsertAll which will insert "All" at the top of a list.
Potential issue: The developer sets the SelectedValues in the Page's PreInit event, but the InsertAll property, if true, will add the "All" value and select it during the control's Init event. The trick is, SelectedValues will directly set the values when set, not later during the life cycle. Which means, when they see the page, they think there is a bug in the component because they didn't set All to be selected, but it is.
Page:
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
listBoxSelection.SelectedValues = "value1,value2";
listBoxSelection.InsertAll = true;
}
Control:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (this.InsertAll)
{
ListBoxItem allItem = new ListBoxItem()
{
Text = "All",
Value = "0"
Selected = true
};
this.Items.Insert(0, allItem);
}
}
How can I ensure that the developer knows they goofed when using this control? This is a simple example, but I see it all the time and in many forms.
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
I'm building a custom server control derived from CompositeControl.
The control contains a number of child controls (Labels, DropDownList, ListSearchExtender, etc). All of them reside inside an UpdatePanel.
The control also publishes events. For this I added two Properties: EnableCallBacks and CallBacksAsPostBacks. Those two properties should configure the postback behaviour of the update panel.
Any ideas what a correct implementation should look like?
I'm getting some problems with the way I implemented it:
the PostBackTrigger does not always get rendered into the output html.
Having both Triggers.Add(trigger) and Controls.Add(_updatePanel) inside the CreateChildControls methods leads to the PostBackTrigger always being rendered, even if I remove it later on (e.g. within RenderControl() or PreRender()). If I do not add the trigger here but later on, then it does never get rendered. At this stage I do not have the correct values of all my properties yet (e.g. EnableCallBacks and CallBacksAsPostBacks).
It is not possible to place the statement of Controls.Add(_updatePanel) inside the RenderControl-method due to it beeing too late for AJAX (latest ist PreRender() otherwise I get an exception).
Ideally I would instantiate all controls in CreateChildControls() and then set their values later on in e.g. PreRender or RenderControl
Having both statements in the PreRender method results in, that the trigger gets rendered corretly depending on my settings in the containing page, but I don't get the DropDownList populated with its data from the ViewState (on call/postbacks).
protected override void CreateChildControls()
{
base.CreateChildControls();
_updatePanel = new UpdatePanel();
_updatePanel.ID = "FprDropDownList_UpPnl";
_updatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
_label = new FprLabel();
_label.ID = "FprDropDownList_Lbl";
_updatePanel.ContentTemplateContainer.Controls.Add(_label);
_dropDownList = new DropDownList();
_dropDownList.ID = "FprDropDownList_Ddl";
_dropDownList.CssClass = "fprDropDownList";
_dropDownList.AutoPostBack = true;
_updatePanel.ContentTemplateContainer.Controls.Add(_dropDownList);
_label.AssociatedControlID = _dropDownList.ClientID;
_listSearchExtender = new ListSearchExtender();
_listSearchExtender.ID = "FprDropDownList_Lse";
_listSearchExtender.TargetControlID = _dropDownList.ClientID;
_listSearchExtender.PromptPosition = ListSearchPromtPosition;
_listSearchExtender.PromptCssClass = "fprListSearchExtender";
_updatePanel.ContentTemplateContainer.Controls.Add(_listSearchExtender);
_ddlPostBackTrigger = new PostBackTrigger();
_ddlPostBackTrigger.ControlID = _dropDownList.ClientID;
//_updatePanel.Triggers.Add(_ddlPostBackTrigger);
Controls.Add(_updatePanel);
}
protected override void OnPreRender(EventArgs pE)
{
if (EnableCallBacks)
{
_dropDownList.SelectedIndexChanged += DropDownList_SelectedIndexChanged;
}
if (EnableCallBacks && CallBacksAsPostBacks)
{
_updatePanel.Triggers.Add(_ddlPostBackTrigger);
}
//Controls.Add(_updatePanel);
base.OnPreRender(pE);
}
public override void RenderControl(HtmlTextWriter pWriter)
{
// Do some things... like set Enable-state of child controls
base.RenderControl(pWriter);
}
You should add your dynamic controls in PreInit for the events to fire properly.
Use this event for the following:
Check the IsPostBack property to
determine whether this is the first
time the page is being processed. The
IsCallback and IsCrossPagePostBack
properties have also been set at this
time.
Create or re-create dynamic
controls.
Set a master page
dynamically.
Set the Theme
property dynamically.
Read or set
profile property values.
I'm trying to enable a double click event on a flex control without disabling the default mouseup/mousedown behaviors.
I'm using the ESRI Flex API for arcgis server, and I have a map control with one background layer and a GraphicLayer. The graphics layer has several Graphic objects that respond to mouseover, and allow the user to pan the map if they click and hold. However, when I implement a double click event handler for the graphic objects, they no longer seem to bubble up their default behavior to the map.
Is there a way to implement a double click on a Graphic object while preserving the old behavior from clicking and holding?
I solved this by attaching the double click event to the map, rather than the graphic, and using the target attribute of the event to get the graphic I wanted to use.
Like this:
map.addEventListener(MouseEvent.DOUBLE_CLICK, function(event:MouseEvent):void
{
var graphic:Graphic = event.target as Graphic;
if(graphic)
{
...
}
});
If you set the "checkForMouseListeners" property to false on your Graphic objects, then the default map click/drag behavior will be preserved.
graphic.addEventListener(MouseEvent.DOUBLE_CLICK, function(event:MouseEvent):void {
var graphic:Graphic = event.target as Graphic;
if(graphic) {
...
}
});
//preserve the default click/drag behavior on the map
graphic.checkForMouseListeners = false;
http://resources.esri.com/help/9.3/ArcGISServer/apis/Flex/apiref/com/esri/ags/Graphic.html#checkForMouseListeners