Search Results

Search found 854 results on 35 pages for 'databinding'.

Page 8/35 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Best practices for using the Entity Framework with WPF DataBinding

    - by Ken Smith
    I'm in the process of building my first real WPF application (i.e., the first intended to be used by someone besides me), and I'm still wrapping my head around the best way to do things in WPF. It's a fairly simple data access application using the still-fairly-new Entity Framework, but I haven't been able to find a lot of guidance online for the best way to use these two technologies (WPF and EF) together. So I thought I'd toss out how I'm approaching it, and see if anyone has any better suggestions. I'm using the Entity Framework with SQL Server 2008. The EF strikes me as both much more complicated than it needs to be, and not yet mature, but Linq-to-SQL is apparently dead, so I might as well use the technology that MS seems to be focusing on. This is a simple application, so I haven't (yet) seen fit to build a separate data layer around it. When I want to get at data, I use fairly simple Linq-to-Entity queries, usually straight from my code-behind, e.g.: var families = from family in entities.Family.Include("Person") orderby family.PrimaryLastName, family.Tag select family; Linq-to-Entity queries return an IOrderedQueryable result, which doesn't automatically reflect changes in the underlying data, e.g., if I add a new record via code to the entity data model, the existence of this new record is not automatically reflected in the various controls referencing the Linq query. Consequently, I'm throwing the results of these queries into an ObservableCollection, to capture underlying data changes: familyOC = new ObservableCollection<Family>(families.ToList()); I then map the ObservableCollection to a CollectionViewSource, so that I can get filtering, sorting, etc., without having to return to the database. familyCVS.Source = familyOC; familyCVS.View.Filter = new Predicate<object>(ApplyFamilyFilter); familyCVS.View.SortDescriptions.Add(new System.ComponentModel.SortDescription("PrimaryLastName", System.ComponentModel.ListSortDirection.Ascending)); familyCVS.View.SortDescriptions.Add(new System.ComponentModel.SortDescription("Tag", System.ComponentModel.ListSortDirection.Ascending)); I then bind the various controls and what-not to that CollectionViewSource: <ListBox DockPanel.Dock="Bottom" Margin="5,5,5,5" Name="familyList" ItemsSource="{Binding Source={StaticResource familyCVS}, Path=., Mode=TwoWay}" IsSynchronizedWithCurrentItem="True" ItemTemplate="{StaticResource familyTemplate}" SelectionChanged="familyList_SelectionChanged" /> When I need to add or delete records/objects, I manually do so from both the entity data model, and the ObservableCollection: private void DeletePerson(Person person) { entities.DeleteObject(person); entities.SaveChanges(); personOC.Remove(person); } I'm generally using StackPanel and DockPanel controls to position elements. Sometimes I'll use a Grid, but it seems hard to maintain: if you want to add a new row to the top of your grid, you have to touch every control directly hosted by the grid to tell it to use a new line. Uggh. (Microsoft has never really seemed to get the DRY concept.) I almost never use the VS WPF designer to add, modify or position controls. The WPF designer that comes with VS is sort of vaguely helpful to see what your form is going to look like, but even then, well, not really, especially if you're using data templates that aren't binding to data that's available at design time. If I need to edit my XAML, I take it like a man and do it manually. Most of my real code is in C# rather than XAML. As I've mentioned elsewhere, entirely aside from the fact that I'm not yet used to "thinking" in it, XAML strikes me as a clunky, ugly language, that also happens to come with poor designer and intellisense support, and that can't be debugged. Uggh. Consequently, whenever I can see clearly how to do something in C# code-behind that I can't easily see how to do in XAML, I do it in C#, with no apologies. There's been plenty written about how it's a good practice to almost never use code-behind in WPF page (say, for event-handling), but so far at least, that makes no sense to me whatsoever. Why should I do something in an ugly, clunky language with god-awful syntax, an astonishingly bad editor, and virtually no type safety, when I can use a nice, clean language like C# that has a world-class editor, near-perfect intellisense, and unparalleled type safety? So that's where I'm at. Any suggestions? Am I missing any big parts of this? Anything that I should really think about doing differently?

    Read the article

  • Entity Framework 4.0 Databinding with sorting not working

    - by Mike Gates
    I want to do something that I thought would be very simple. I want to bind a generated Entity Framework EntityCollection to a WPF DataGrid. I also want this grid to be sortable. I have tried all kinds of things to make this happen, including using a CollectionViewSource. However, nothing seems to work. Using a normal CollectionViewSource around the EntityCollection gives me: 'System.Windows.Data.BindingListCollectionView' view does not support sorting. Ok...strange. I would have thought this would work. Next on the CollectionViewSource, I try setting: CollectionViewType="ListCollectionView" Great, sorting now works. But wait, I can't add or remove entities using the grid now, presumably because ListCollectionView doesn't support this with an entity framework context. So, I guess I need to capture events coming out of the datagrid in order to add or remove entities manually from my context. Now I can't find an event to capture to detect an add...! Why is this so hard? This should be the standard "demo" case that Microsoft should have designed around. Any ideas?

    Read the article

  • zk combobox databinding

    - by user121196
    The zk code below only shows on item... I need it to show all elements in tmp. any idea? thanks <zscript> List tmp=Arrays.asList(new String[]{"a","b","c"}); ]]> </zscript> <combobox id="mycb" model="@{tmp}"> <comboitem self="@{each=row}" label="xxx" value="yyy"> </comboitem> </combobox>

    Read the article

  • UpdatePanel, Repeater, DataBinding Problem

    - by Gordon Carpenter-Thompson
    In a user control, I've got a Repeater inside of an UpdatePanel (which id displayed inside of a ModalPopupExtender. The Repeater is databound using an array list of MyDTO objects. There are two buttons for each Item in the list. Upon binding the ImageURL and CommandArgument are set. This code works fine the first time around but the CommandArgument is wrong thereafter. It seems like the display is updated correctly but the DTO isn't and the CommandArgument sent is the one that has just been removed. Can anybody spot any problems with the code? ASCX <asp:UpdatePanel ID="ViewDataDetail" runat="server" ChildrenAsTriggers="true"> <Triggers> <asp:PostBackTrigger ControlID="ViewDataCloseButton" /> <asp:AsyncPostBackTrigger ControlID="DataRepeater" /> </Triggers> <ContentTemplate> <table width="100%" id="DataResults"> <asp:Repeater ID="DataRepeater" runat="server" OnItemCommand="DataRepeater_ItemCommand" OnItemDataBound="DataRepeater_ItemDataBound"> <HeaderTemplate> <tr> <th><b>Name</b></th> <th><b>&nbsp;</b></th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td> <b><%#((MyDTO)Container.DataItem).Name%></b> </td> <td> <asp:ImageButton CausesValidation="false" ID="DeleteData" CommandName="Delete" runat="server" /> <asp:ImageButton CausesValidation="false" ID="RunData" CommandName="Run" runat="server" /> </td> </tr> <tr> <td colspan="2"> <table> <tr> <td>Description : </td> <td><%#((MyDTO)Container.DataItem).Description%></td> </tr> <tr> <td>Search Text : </td> <td><%#((MyDTO)Container.DataItem).Text%></td> </tr> </table> </td> </tr> </ItemTemplate> </asp:Repeater> </table> </ContentTemplate> </asp:UpdatePanel> Code-Behind public DeleteData DeleteDataDelegate; public RetrieveData PopulateDataDelegate; public delegate ArrayList RetrieveData(); public delegate void DeleteData(String sData); protected void Page_Load(object sender, EventArgs e) { //load the initial data.. if (!Page.IsPostBack) { if (PopulateDataDelegate != null) { this.DataRepeater.DataSource = this.PopulateDataDelegate(); this.DataRepeater.DataBind(); } } } protected void DataRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete") { if (DeleteDataDelegate != null) { DeleteDataDelegate((String)e.CommandArgument); BindDataToRepeater(); } } else if (e.CommandName == "Run") { String sRunning = (String)e.CommandArgument; this.ViewDataModalPopupExtender.Hide(); } } protected void DataRepeater_ItemDataBound(object source, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if (item != null && item.DataItem != null) { MyDTO oQuery = (MyDTO)item.DataItem; ImageButton oDeleteControl = (ImageButton) item.FindControl("DeleteData"); ImageButton oRunControl = (ImageButton)item.FindControl("RunData"); if (oDeleteControl != null && oRunControl !=null) { oRunControl.ImageUrl = "button_expand.gif"; oRunControl.CommandArgument = "MyID"; oDeleteControl.ImageUrl = "btn_remove.gif"; oDeleteControl.CommandArgument = "MyID"; } } } public void BindDataToRepeater() { this.DataRepeater.DataSource = this.PopulateDataDelegate(); this.DataRepeater.DataBind(); } public void ShowModal(object sender, EventArgs e) { BindDataToRepeater(); this.ViewDataModalPopupExtender.Show(); }

    Read the article

  • LoginView inside FormView control is not databinding on PostBack

    - by subkamran
    I have a fairly simple form: <asp:FormView> <EditItemTemplate> <asp:LoginView> <RoleGroups> <asp:RoleGroup roles="Blah"> <ContentTemplate> <!-- Databound Controls using Bind/Eval --> </ContentTemplate> </asp:RoleGroup> </RoleGroups> </asp:LoginView> <!-- Databound Controls --> </EditItemTemplate> </asp:FormView> <asp:LinqDataSource OnUpdating="MyDataSource_Updating" /> I handle my LinqDataSource OnUpdating event and do some work handling some M:N fields. That all works. However, once the update is finished (and I call e.Cancel = true), the LoginView control does not databind its children... so they are all blank. The FormView's viewstate is still fine, as all the rest of the controls outside of the LoginView appear fine. I even handle the FormView_DataBound event and a Trace shows that the FormView is being databound on postback. Why then is the LoginView not keeping its ViewState/being databound? Here's a sample code snippet showing the flow: protected void MyDataSource_Updating(object s, LinqDataSourceUpdateEventArgs e) { try { Controller.DoSomething(newData); // attempts to databind again here fail // frmView.DataBind(); // MyDataSource.DataBind(); // LoginView.DataBind(); } catch { // blah } finally { e.Cancel = true; } }

    Read the article

  • WPF: Databinding and Combo Boxes

    - by Jonathan Allen
    I have two classes Company CompanyKey CompanyName Person FirstName LastName CompanyKey The list items on the combo box is bound to a collection of CompanyObjects. How to I databind the selected item property of the Combobox to the Person.CompanyKey property?

    Read the article

  • Databinding int32 to MaskedEditExtender enabled TextBox

    - by Zach Skinner
    I have a master/detail scheme for editing an asp:GridView using an asp:DetailsView. One of my fields is for a phone number of type int64 (always 10 digits). I would like this field to always be displayed as (###)###-####. My issue is the first digit in the phone number is always truncated for my edit item field which I used a MaskedEditExtender to achieve the formatting. Here is my EditItemTemplate for the details view: <cc1:MaskedEditExtender TargetControlID="edtPROJ_Leader_Phone" Mask="(999)999-9999" runat="server" ClearMaskOnLostFocus="false" ClipboardEnabled="true" MaskType="Number" /> <asp:TextBox ID="edtPROJ_Leader_Phone" runat="server" Text='<%# Bind("PROJ_Leader_Phone") %>' ></asp:TextBox> When my details view is displayed for editing, the text box displays(_23)456-7890 for the integer 1234567890. Also worth noting that if the property MaskType="Number" is removed, the textbox shows: (234)567-890_. I would of course have the textbox show (123)-546-67890 after binding.

    Read the article

  • Databinding problem in dropdownlist box by generics in C#

    - by sakir-ali
    I want to implement stack in my program by Genericx. I have a textbox and button to add elements in stack, a dropdownlist box and a button to bind total stack in dropdownlist box. I have generic class and the code is below: [Serializable] public class myGenClass<T> { private T[] _elements; private int _pointer; public myGenClass(int size) { _elements = new T[size]; _pointer = 0; } public void Push(T item) { if (_pointer > _elements.Length - 1) { throw new Exception("Stack is full"); } _elements[_pointer] = item; _pointer++; } public T Pop() { _pointer--; if (_pointer < 0) { throw new Exception("Stack is empty"); } return _elements[_pointer]; } public T[] myBind() { T[] showall = new T[_pointer]; Array.Copy(_elements,showall, _pointer); T[] newarray = showall; Array.Reverse(showall); return showall; } } and my .cs page is below: public partial class _Default : System.Web.UI.Page { myGenClass<int> mystack = new myGenClass<int>(25); protected void Button1_Click(object sender, EventArgs e) { mystack.Push(Int32.Parse(TextBox1.Text)); //DropDownList1.Items.Add(mystack.Pop().ToString()); TextBox1.Text = string.Empty; TextBox1.Focus(); } protected void Button2_Click(object sender, EventArgs e) { //string[] db; //db = Array.ConvertAll<int, string>(mystack.myBind(), Convert.ToString); DropDownList1.DataSource = mystack.myBind(); DropDownList1.DataBind(); } } but when I bind the datasource property of dropdownlist box to generic type return array (i.e. myBind()), it shows empty... Please help..

    Read the article

  • DataBinding: ComboBox.Text not updating when SelectedValue changes?

    - by Rob
    This is the relevant designer code for the ComboBox: Me.ProbationComboBox.DataBindings.Add(New System.Windows.Forms.Binding("Enabled", Me.RegistrationBindingSource, "IsRegistered", True)) Me.ProbationComboBox.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.RegistrationBindingSource, "ProbationID", True)) Me.ProbationComboBox.DataSource = Me.ProbationBindingSource Me.ProbationComboBox.DisplayMember = "probation" Me.ProbationComboBox.ValueMember = "id" The problem is that when I call RegistrationBindingSource.ResetCurrentItem(), the SelectedValue property is refreshed with the correct value from RegistrationBindingSource.ProbationID(). However, the Text property is not updated. Until I can figure out the problem with my binding, I've been doing this as a fix: Me.ProbationComboBox.Text = CType(CType(Me.ProbationBindingSource.Current, DataRowView).Row, RootNamespace.DataSet.probationRow).probation Any ideas? Your assistance is appreciated!

    Read the article

  • Equivalent of Flex DataBinding using Pure Actionscript

    - by Joshua
    What is the ActionScript equivalent of this? <mx:Label text="Hello {MyVar} World!"/> In ActionScript it would need it to look something like this: var StringToBind="Hello {MyVar} World!"; // I've Written It This Way Because I Don't Know The Exact Text To Be Bound At Design Time. [Bindable] var MyVar:String='Flex'; var Lab:Label=new Label(); Lab.text=??? ... SomeContainer.addChild(Lab); How can I accomplish this kind of "Dynamic" binding... Where I don't know the value of "StringToBind" until runtime? For the purposes of this question we can assume that I do know that any variable mentioned in "StringToBind", is guaranteed to exist at runtime. I already realize there are much more straightforward ways to accomplish this exact thing STATICALLY, and using only Flex. It's important for my project though that I understand how this could be accomplished using purely ActionScript.

    Read the article

  • GridView not DataBinding Automatically after ObjectDataSource Select Method

    - by John Polvora
    I've created a objectadasource that returns a datatable, the gridview is binded to this datasource. the ODS have parameters assigned on the Page_Load event, and the ODS returns the data ok and the gridview shows it fine. the problem is i have a textbox with a filter. first I created a filterexpression in gridview, using the contents of the textbox, worked fine for me. but now I've enabled the paging in gridview. then the filterexpression is not useful now, since the ODS returns only the rows of the pagesize of gridview. I did a new ODS method that select data from parameters page and pagesize according to GridView, and it's OK. now my filter textbox passes his text property to a parameter of the ods select method, then the ods gets the data based on my filter and shows it in the grid. on the Page_Load: ObjectDataSource_Lista.SelectParameters["search"].DefaultValue = filter; ObjectDataSource_Lista.SelectParameters["id"].DefaultValue = ID.ToString(); but when I change the value of the filter, the grid doesn't refresh. on debugging. I see that the ODS Select Method is refreshed ok, but the GridView don't. So I need to call mannually the Databind() method of the grid, to refresh data. the problem is, I have a commandbutton on the grid, and if I manually databind(), the command button stops functioning, generating Page ValidateRequest errors. My question is: how to databind() the grid automatically after the datasource refreshed? ps: on the ODS Selected event, causes a infinite loop and the debug webserver crashes. Temporary solution: Created a Variable private bool wasdatabound; on the event GridView_Databound, set wasdatabound = true; on the Page_PreRenderComplete, if ((GridView1.Visible) && (!databounded)) GridView1.DataBind();

    Read the article

  • DataBinding a DropDownList in ASP.NET MVC 2

    - by Daniel Coffman
    I'm extremely frustrated trying to switch to MVC after a couple years of webforms development. Here's my extremely simple problem that I can't manage to solve: I have a list of States in a table called StateProvince. I have a DropDownList. I want the DropDownList to display all of the States in the StateProvince table and post the selected state back on HTTP PUT. This is what I'm doing: <%: Html.DropDownListFor(model = model.StateProvinceId, new SelectList(Model.StateProvinces, "StateProvinceId", "Name") )% I'm getting an Object reference not set to an instance of an object. Why? How can I make this work? Keep it simple, I know nothing about MVC.

    Read the article

  • wpf c# databinding on object

    - by Enriquev
    Hello, say I have this control: public partial class bloc999 : UserControl { bloc999Data mainBlock = new bloc999Data(); public bloc999() { InitializeComponent(); mainBlock.txtContents = "100"; base.DataContext = mainBlock; } } in the xaml: <TextBox Margin="74,116,106,0" Name="txtContents" Text="{Binding Path=txtContents, UpdateSourceTrigger=PropertyChanged,Mode = TwoWay}" /> <TextBox Margin="74,145,106,132" Name="txtContents2" Text="{Binding Path=txtContents2, UpdateSourceTrigger=PropertyChanged,Mode = TwoWay}" /> Then I have this class: public class bloc999Data : INotifyPropertyChanged { string _txtContents; string _txtContents2; public event PropertyChangedEventHandler PropertyChanged; void NotifyPropertyChanged(string propName) { if (this.PropertyChanged != null) this.PropertyChanged( this, new PropertyChangedEventArgs(propName)); } public string txtContents2 { get { return this._txtContents2; } set { if (int.Parse(value) > int.Parse(this._txtContents)) { this._txtContents2 = "000"; } else this._txtContents2 = value; NotifyPropertyChanged("txtContents2"); } } public string txtContents { get { return this._txtContents; } set { this._txtContents = value; NotifyPropertyChanged("txtContents"); } } } Ok now say I have A button on the form and I do this in the code: mainBlock.txtContents2 = "7777777"; It puts 000 in the textbox, but If i just type in manually, in the textbox (txtContents2, the setter code is called but for some reason the textboxes value does not change, the instance value does change. help?

    Read the article

  • 2-Way databinding with Entity Framework and WPF DataGrid

    - by Mike Gates
    I'm having trouble adding an Entity Framework entity to a ObjectContext's EntitySet automatically using the WPF 4.0 DataGrid's add functionality. Here's the setup: DataGrid--BoundTo--ListCollectionView--BoundTo--EntitySet When I interactively add a row to the DataGrid, the EntitySet does not have a new entity added to it. Updating the row's cell data does in fact update the bound entity's properties, however. Any idea what I could be doing wrong?

    Read the article

  • ListBox Items Not Visible after DataBinding

    - by SidC
    Good Evening All, I am writing a page that allows users to search a parts table, select quantities and a listbox is to be populated with gridview values. Here's a snippet of my aspx page: <asp:ListBox runat="server" ID="lbItems" Width="155px"> <asp:ListItem></asp:ListItem> <asp:ListItem></asp:ListItem> <asp:ListItem></asp:ListItem> <asp:ListItem></asp:ListItem> <asp:ListItem></asp:ListItem> </asp:ListBox> Here's the relevant contents of codebehind: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Define DataTable Columns as incoming gridview fields Dim dtSelParts As DataTable = New DataTable Dim dr As DataRow = dtSelParts.NewRow() dtSelParts.Columns.Add("PartNumber") dtSelParts.Columns.Add("NSN") dtSelParts.Columns.Add("PartName") dtSelParts.Columns.Add("Qty") 'Select those gridview rows that have txtQty <> 0 For Each row As GridViewRow In MySearch.Rows Dim textboxText As String = _ CType(row.FindControl("txtQty"), TextBox).Text If textboxText <> "0" Then 'Create the row dr = dtSelParts.NewRow() 'Fill the row with data dr("PartNumber") = MySearch.DataKeys(row.RowIndex)("PartNumber") dr("NSN") = MySearch.DataKeys(row.RowIndex)("NSN") dr("PartName") = MySearch.DataKeys(row.RowIndex)("PartName") 'Add the row to the table dtSelParts.Rows.Add(dr) End If Next 'Need to send items to Listbox control lbItems lbItems.DataSource = New DataView(dtSelParts) lbItems.DataValueField = "PartNumber" lbItems.DataValueField = "NSN" lbItems.DataValueField = "PartName" lbItems.DataBind() End Sub The page runs fine in that my search functiobnality is intact, and I can input quantity values into my gridview's textbox. When I click Add to Quote the Listbox receives focus, but no list items are visible. I've created several list items in the aspx page, however I don't know how to populate the contents of my datatable in the listbox. Can someone help a newbie with this, seemingly, easy issue? Thanks, Sid

    Read the article

  • asp.net databinding string is passed to function but runtime occurs

    - by rod
    Hi All, I'm using a code-behind function (called TestFx) in my binding expression. I'm passing a string and the function accepts a string but I still get a runtime error saying invalid args. But if I change the method to accept an object and inspect the value, "it's a string!" Can someone please explain? -rod ProductDescription: <asp:Label ID="ProductDescriptionLabel" runat="server" Text='<%# TestFx(Eval("ProductDescription")) %>' /> <br />

    Read the article

  • What exactly is Two-way databinding in WPF ?

    - by blntechie
    I'm learning WPF with MVVM and for a starter, I viewed Jason Dolinger's video on MVVM . In that he mentioned, that one of the advantage of using MVVM with WPF is two-way data binding. My question is what does he mean by two-way data binding? Is that the feature of ability to 1) bind data from controls(View) to properties in VM and 2) any change in collections or properties are reflected in the view? If I'm wrong, can anyone please explain me in detail what it is and what are its advantages? This might be a very simple doubt, but I'm very new to WPF and it's terminologies and moving away from WinForms now.

    Read the article

  • Flex DataBinding Drilling Down Through Arrays

    - by Joshua
    The help page on the BindUtils.bindProperty function: http://livedocs.adobe.com/flex/3/langref/mx/binding/utils/BindingUtils.html Has this to say: "For example, to bind the property host.a.b.c, call the method as: bindProperty(host, ["a","b","c"], ...)." But what if I need to bind to host.a.b[2].c? How do I do that?

    Read the article

  • ASP.NET - DropDown DataBinding (Rebind?)

    - by Bob Fincheimer
    I have a drop down which has a method which binds data to it: dropDown.Items.Clear() dropDown.AppendDataBoundItems = True Select Case selType Case SelectionTypes.Empty dropDown.Items.Insert(0, New ListItem("", "")) Case SelectionTypes.Any dropDown.Items.Insert(0, New ListItem("ANY", "")) Case SelectionTypes.Select dropDown.Items.Insert(0, New ListItem("Select One", "")) End Select BindDropDown(val) The BindDropDown method simply sets the datasource, datakeyname, datavaluename, and then databinds the data. For a reason which I cannot avoid, I MUST call this method twice sometimes. When it is called twice, All of the databound items show up two times, but the top item (the one I manually insert) is there only once. Is ASP doing something wierd when i databind twice even though i clear the list between? Or does it have to do something with the viewstate/controlstate? EDIT__ The entire page, and this control has EnableViewState="false" EDIT___ The dropdown is inside a form view. After the selected value is set I have to rebind the dropdown just in case the selected value is not there [because it is an inactive user]. After this, the formview duplicates the databound items.

    Read the article

  • Hang during databinding of large amount of data to WPF DataGrid

    - by nihi_l_ist
    Im using WPFToolkit datagrid control and do the binding in such way: <WpfToolkit:DataGrid x:Name="dgGeneral" SelectionMode="Single" SelectionUnit="FullRow" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" Grid.Row="1" ItemsSource="{Binding Path=Conversations}" > public List<CONVERSATION> Conversations { get { return conversations; } set { if (conversations != value) { conversations = value; NotifyPropertyChanged("Conversations"); } } } public event PropertyChangedEventHandler PropertyChanged; public void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public void GenerateData() { BackgroundWorker bw = new BackgroundWorker(); bw.WorkerSupportsCancellation = bw.WorkerReportsProgress = true; List<CONVERSATION> list = new List<CONVERSATION>(); bw.DoWork += delegate { list = RefreshGeneralData(); }; bw.RunWorkerCompleted += delegate { try { Conversations = list; } catch (Exception ex) { CustomException.ExceptionLogCustomMessage(ex); } }; bw.RunWorkerAsync(); } And than in the main window i call GenerateData() after setting DataCotext of the window to instance of the class, containing GenerateData(). RefreshGeneralData() returns some list of data i want and it returns it fast. Overall there are near 2000 records and 6 columns(im not posting the code i used during grid's initialization, because i dont think it can be the reason) and the grid hangs for almost 10 secs!

    Read the article

  • Populate two column grid with databinding?

    - by Richard
    How do i populate a two column grid with objects from my observable collection? I've tried to achieve this effect by using the tookits wrap panel but the items just stack. <toolkit:WrapPanel Margin="5,0,0,0" Width="400"> <ItemsControl ItemsSource="{Binding Trips}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Height="236" Width="182"> <Button Style="{StaticResource VasttrafikButtonTrip}"> <StackPanel Width="152" Height="140"> <TextBlock Text="{Binding FromName}" /> <TextBlock FontFamily="Segoe WP Semibold" Text="till" /> <TextBlock Text="{Binding ToName}" /> </StackPanel> </Button> <TextBlock HorizontalAlignment="Left" Width="160" FontSize="16" FontWeight="ExtraBlack" Text="{Binding TravelTimeText}" /> <TextBlock HorizontalAlignment="Left" Width="160" Margin="0,-6,0,0" FontSize="16" Text="{Binding TransferCountText}" /> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </toolkit:WrapPanel>

    Read the article

  • Databinding in Visual Studio with Silverlight

    - by cam
    I want to achieve the following exactly: http://geekswithblogs.net/tkokke/archive/2009/04/01/creating-binding-and-styling-a-bubble-chart.aspx The Silverlight Toolkit is giving me hell. I'm trying to create a simple chart in Visual Studio 2010. I've drawn the chart on the screen, but I can't figure out how to add data to it.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >