I have a silverlight form where in i am populating a datagrid in the constructor of the form, below is the code...
public partial class ManageArtists : UserControl
{
ChinookDomainContext cdContext = new ChinookDomainContext();
public ManageArtists()
{
InitializeComponent();
cdContext.Load(cdContext.GetArtistsQuery());
dpArtistPager.Source = cdContext.Artists.OrderBy(artist => artist.Name);
dgArtistList.ItemsSource = cdContext.Artists.OrderBy(artist => artist.Name);
}
}
Now the problem is....Even though the data is loaded in the grid it does not show anything until i click on the Header fields of the grid. I dont understand why is this happening ??
can someone explain me whats happening !!
thank you
In this line -
dgArtistList.ItemsSource = cdContext.Artists.OrderBy(artist => artist.Name);
you'll find that your ItemsSource is being set to an instance of IOrderedEnumerable,..which doesn't support property changed notification.
To fix this quickly and easily wrap that collection in an ObservableCollection and your data should display correctly.
HTH
Related
I have created a custom checkbox template field by deriving it from System.Web.UI.WebControls.TemplateField. The template for this field has been created by creating a class which implements ITemplate interface. When any postback happens on the page the values in the checkboxes is lost.
To get this working temporarily I have used viewstate to store the state of checkboxes in the checkbox column, but going further I want to completely avoid this as I will be using more template fields in same fashion in my application.
Please let me know if I am missing anything.
Following is the code:
namespace MyControls
{
public class CheckBoxTemplateField : TemplateField
{
public CheckBoxTemplateField()
{
this.HeaderTemplate = new CheckBoxTemplate();
this.ItemTemplate = new CheckBoxTemplate();
}
}
public class CheckBoxTemplate : ITemplate
{
public void InstantiateIn(Control container)
{
CheckBox chk = new CheckBox();
container.Controls.Add(chk);
}
}
}
Regards,
Gaurav
checkbox is known with their problem maintaining their value in postback
1 solution is to store its value in hidden fiesld and to read it in server.
p.s. thhis has nothing to do with viewstate.input control doesnt saves their value in viewstate ( excpet textbox which has the 'ontextchange' event)
I created a SWT based Wizard which has an own help Button by custom. Now i want to put some content behind that, so maybe a SWT browser will be openend and a predifined HTML Doc will be shown. But I don't have any clue where to access the Actions of the Help Button within my Wizard. Any idea?
I am assuming that you are using the standard JFace interfaces and classes for the wizard implementation. So, in your wizard page (extending org.eclipse.jface.wizard.WizardPage) you just have to override the performHelp method. See the below snippet.
#Override
public void performHelp()
{
Shell shell = new Shell(getShell());
shell.setText("My Custom Help !!");
shell.setLayout(new GridLayout());
shell.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Browser browser = new Browser(shell, SWT.NONE);
browser.setUrl("http://stackoverflow.com/questions/7322489/cant-put-content-behind-swt-wizard-help-button");
browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
shell.open();
}
>>Wizard image
>>After pressing the help button
I'm implementing the ITemplate interface in ListView control. If i realize it for ItemTemplate in my custom class, everything will be OK. I mean, the runtime will invoke InstantiateIn when i use
ListView.ItemTemplate = new CustomClass();
CustomClass :ITemplate
{
public void InstantiateIn(Control container)
{
HtmlTable table = CreateHeader();
container.Controls.Add(table);
}
...
}
But i want to do the same with ListView.LayoutTemplate. In this case, the runtime invokes InstantiateIn only one time, but every next update it leaves my method. What is the reason for it?
Layout template says how the root container does look like, it is not per item thing.
I have to change my LayoutTemplate after clicking different buttons.
And My LayoutTemplate has a header for the whole ListView. I have to change it, it depends on button.
Also i have two custom classes with implementations of ITemplate (one for ItemTemplate and one for LayoutTemplate). I am going to realise the folowing behaviour:
1). If i click Button1
ListView.ItemTemplate = new CustomItemClass1();
ListView.LayoutTemplate = new CustomLayuotClass1();
2). If i click Button2
ListView.ItemTemplate = new CustomItemClass2();
ListView.LayoutTemplate = new CustomLayuotClass2();
But i can't see my header of LayoutTemplate more, then one time.
I have a ASP.NET treeview populated with custom treenodes (ExtensionRangeTreeNode subclassed from TreeNode).
On postback the treeview is populated with TreeNodes, not my custom treenode class.
What's up with this?
Thanks,
BP
This forum entry may answer the question :
Basically, it is said a custom treeview control has to be used. CreateNode function must be overriden to instanciate the right TreeNode type. Here, it would be ExtensionRangeTreeNode instead of "CustomTreeNode".
public class CustomTreeView : TreeView
{
protected override TreeNode CreateNode()
{
return new CustomTreeNode(this, false);
}
}
Of course, you will have to add the ExtensionRangeTreeNode(Treeview treeview, bool isRoot) constructor signature to your current ExtensionRangeTreeNode implementation.
Without looking at your particular code, I can only assume that you custom TreeNode is not using ViewState. This would explain why it is not getting populated on postback.
DoesExtensionRangeTreeNode fully handle saving itself to the viewstate fully? If so, can you cast the returned nodes to that type?
in my flex application, I created a Tilelist. In this Tilelist, I am using an ItemRenderer to create a box consisting of an image and an VSlider in each tile.
The tile need to be dragable when you click on the image, but not dragable when you slide the slider. How can I achieve this ? I have been scratching my head searching on Google for one day and I have really no idea.
I look forward to your help.
Thank you.
I found a solution to my problem, however it may not be the best one.
Using this :
public var overImage:Boolean = false;
public function checkAllow(evt:DragEvent):void {
if(overImage == false)
{
evt.preventDefault()
}
}
public function isOverImage():void {
overImage = true;
}
public function isOutImage():void {
overImage = false;
}
I call those functions like this :
On my image component
mouseOver="outerDocument.isOverImage()" mouseOut="outerDocument.isOutImage()"
And for my tilelist I did this
Tiles.addEventListener(DragEvent.DRAG_START, checkAllow);
Hope it helps some people.
if(event.target is ScrollThumb )
{
return;
}
problem solved by returning the scrollThumb property of sroller in imageDragStart method...
BackGround:My TileList is provided with mouseDown ="event.currentTarget.addEventListener(MouseEvent.MOUSE_MOVE, imageDragStart )";
which was effecting complete TileList along with scroller ,
This above was the temp fix, but expecting experts suggestions.
Basically this is for Native application (AIR), used NativeDragStart. but am forced to use mouseDown over my TileList to invoke imageStartDrag() method of mine....