Search Results

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

Page 15/35 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • When giving DataSource to a BindingSource shows only the cachedList Items.

    - by gtas
    I have a BindingSource on a form with MyObject Datasource. I Open another form and passing MyObject where i give its EntitySetObject reference to another BindingSource. Everything ok. Deleting an Entity on EntitySetObject reference and closing the form with EndEdit(). OK. Back in the "First" form i add one Entity in MyObject.EntitySetObject and again opening the form. But i have noticed that when giving the datasource to the BindingSource i have 2 items in cachedlist and 3 entities. Control now shows only the 2 cached items. Any Idea?

    Read the article

  • Get the value for a WPF binding

    - by Jose
    Ok, I didn't want a bunch of ICommands in my MVVM ViewModels so I decided to create a MarkupExtension for WPF that you feed it a string(the name of the method), and it gives you back an ICommand that executes the method. here's a snippet: public class MethodCall : MarkupExtension { public MethodCall(string methodName) { MethodName = methodName; CanExecute = "Can" + methodName; } public override object ProvideValue(IServiceProvider serviceProvider) { Binding bin= new Binding { Converter = new MethodConverter(MethodName,CanExecute) }; return bin.ProvideValue(serviceProvider); } } public class MethodConverter : IValueConverter { string MethodName; public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { //Convert to ICommand ICommand cmd = ConvertToICommand(); if (cmd == null) Debug.WriteLine(string.Format("Could not bind to method 'MyMethod' on object",MethodName)); return cmd; } } It works great, except when the binding fails(e.g. you mistype). When you do this in xaml: {Binding MyPropertyName} you see in the output window whenever the binding fails. and it tells you the propertyName the Type name etc. The MethodConverter Class can tell you the name of the method that failed, but it can't tell you the source object type. Because the value will be null. I can't figure out how to store the source object type so for the following class public class MyClass { public void MyMethod() { } } and the following xaml: <Button Command={d:MethodCall MyMethod}>My Method</Button> It currently says: "Could not bind to method 'MyMethod' on object but I would like it to say: "Could not bind to method 'MyMethod' on object MyClass Any ideas?

    Read the article

  • How do I specify table data only for the current user's ID (VWD asp.net 3.5) ?

    - by Greg McNulty
    I'm using the Details View control of VWD asp.net 2008 I have a users database table and one of the columns contain the "unique" user's profile ID, created by VWD from the automatic profiles table. From my table, I would like to select only the data pertaining to the logged in user. How do I get the current unique user profileID and then have that used for the query? What I have so far: In the configure data source option of the control I select the columns I would like to display, select the check box for "Return Only Unique IDs" and the WHERE option. In this new window I select the Column to the profile userID ... "=" and then assumed I should select Source: "Profile". Now what should the parameter properties or value be to select only the logged userID specific data of the table? Any help is appreciated. Thank You!

    Read the article

  • C# WPF DataBind boolean

    - by jtdangelo
    I have been using this website to learn a lot about C# for a while, but this is my first time posting a question. I look forward to hearing back from some of the seasoned C# veterans! I have been working on a C# 4.0 WPF project and need to figure out how to databind a boolean value. I have a reference to my Application.Current object in a window. My "App" object contains a boolean field called "Downloaded" that is true if the user has downloaded information from a web service. I need to databind a textbox's IsEnabled field to this Downloaded value. Any tips? Here is what I have come up with so far. (Any useful links to better learn WPF XAML are greatly appreciated!) C# Code: class MainWindow : Window { ... private App MyApp = App.Current as App; ... } XAML: <TextBox ... IsEnabled="{Binding Source=MyApp, Path=Downloaded}" /> James

    Read the article

  • WPF: Problem with SelectedItem for ComboBox

    - by Anry
    XAML: <ComboBox Height="27" Margin="124,0,30,116" Name="cbProductDefaultVatRate" VerticalAlignment="Bottom" ItemsSource="{Binding}"> <ComboBox.ItemTemplate> <DataTemplate> <Label Height="26" Content="{Binding Path=Value}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> Set Data for cbProductDefaultVatRate.Items (Type - VatRate): private void ShowAllVatRates() { cbProductDefaultVatRate.Items.Clear(); cbProductDefaultVatRate.ItemsSource = new VatRateRepository().GetAll(); } Similarly, I defined property: private Product SelectedProduct { get; set; } The Product contains VatRate: SelectedProduct.DefaultVatRate How to set SelectedItem equal SelectedProduct.DefaultVatRate? I tried: cbProductDefaultVatRate.SelectedItem = SelectedProduct.DefaultVatRate; But it does not work. Thank you for answers!

    Read the article

  • Binding to TreeView in WPF

    - by KrisTrip
    I am trying to bind some data from a class instance to a TreeView. My code is as follows: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Parent myClass = new Parent(); this.DataContext = myClass; } } public class Parent { public String Name; public List<string> Children = new List<string>(); private static int count = 0; public Parent() { this.Name = "Test"; for (int i = 0; i < 10; i++) { Children.Add(i.ToString()); } } } And the XAML: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loc="clr-namespace:WpfApplication1" Title="MainWindow" Height="287" Width="525"> <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch"> <TreeView Name="TreeView" ItemsSource="{Binding}"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Children}"> <TextBlock Text="{Binding Name}"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> </StackPanel> </Window> Nothing shows up in my TreeView. What am I doing wrong?

    Read the article

  • How come nobody wrote RadioMenuItems class for Winforms?

    - by Pavel Radzivilovsky
    Or maybe google is just not so friendly to me? What I want is this simple thing: constructor that accepts an array of menu item objects Value get/set property that would set all the Checked properties right bind to all Clicked events of the supplied items and provide One event Working DataBind facilities If you encountered such a nice thing around, please direct me. No need for manual do-it-in-your-form1.cs-class links, please. This I can do myself.

    Read the article

  • WPF USer Control viewmodel binding

    - by Senthilkumar
    HI Can any one suggest me how bind viewmodel to a usercontrol.. Also please share different way of doing that.. I have added viewmodel and view into my xaml file in namespace and in the user control resource tag.. i have defined a data template with data type as the viewmodel wh i have wrote.. inside that i have added my view (i mean the same usercontrol ih which im editing now is it possible -- please let me know).. I have used content control with content={Binding}.. and contenttemplate as a datatemplate.. in that i have reffered the property which i want to bind from viewmodel).. but its not binding as such.. My query is different ways of binding viewmodel to view in UserControlLibrary Project ?

    Read the article

  • Bind a users role to dropdown?

    - by Dynde
    Hi... I'm trying to bind a selected user's role to a dropdown-list. The purpose of this is to be able to change said user's role. I'm attempting this inside a formview hooked up to a linqdatasource which contains a row from the aspnet_User table. The dropdown list is hooked up to a linqdatasource of all the roles in the aspnet_Roles table (with DataValueField="RoleID", DataTextField="RoleName"). I figured it would be possible with something like: SelectedValue='<%# Bind("aspnet_UsersInRole[0].aspnet_Role.RoleID") %>' But this throws a parser exception, about the bind call not being correctly formatted. The roles are there, they show up when I remove the "SelectedValue" Can anyone point me in the right direction?

    Read the article

  • ASP.NET Binding integer to CheckBox's Checked field

    - by Sung Meister
    I have a following ListView item template, in which I am trying to bind integer value to Checked property of CheckBox. IsUploaded value contains only 0 and 1... <asp:ListView ID="trustListView" runat="server"> <ItemTemplate> <asp:CheckBox ID="isUploadedCheckBox" runat="server" Checked='<%# Bind("IsUploaded") %>' /> </ItemTemplate> </asp:ListView> But ASP.NET complains that Exception Details: System.InvalidCastException: Sepcified cast is not valid Even though following code using DataBinder.Eval() works, I need to have a 2-way binding, thus need to use Bind(). <asp:CheckBox ID="isUploadedCheckBox2" runat="server" Checked='<%# Convert.ToBoolean( DataBinder.Eval(Container.DataItem, "IsUploaded"))) %>' /> How can I convert 0's and 1's to boolean using Bind()? [ANSWER] I have extended auto-generated type through partial class by adding a new property mentioned in the answer by Justin

    Read the article

  • Current ways to do data binding in .NET 3.5 with C# 3.0 and WinForms

    - by kryptic
    Hello Everyone, I have an existing C# 3.0 WinForms project with .NET 3.5 that talks to a MySQL database. I would like to use data binding (I'm new to this, so I've been doing all of the UI updates manually) to simplify things. I followed a link from this question to this article which mentions using a DataSet but also follows up with "my view on this topic is strongly in favor of Business Objects." Also that was with .NET 2.0. What are the current methods to use data binding with a WinForms application? What are their advantages in terms of simplicity, how much additional code is necessary, etc. For reference, I use an ORM approach to build objects with public properties from a database. I want to map these properties for each object onto UI elements like TextBoxes. There could be many properties for an object so I want to simplify the code to do this.

    Read the article

  • Bind DataGrid to Dictionary in ASP.NET

    - by mcoolbeth
    In ASP.NET, binding a DataGrid to a list of objects is super-easy. I end up with a row for each object in the list, and any cell in a given row is bound to a property of the corresponding object. However, suppose one of the properties of my object is a dictionary, and each is expected to contain a specific key. Is there any way to bind one of my DataGridColumns to that dictionary key? Thanks.

    Read the article

  • Help with Linq Expression - INotifyPropertyChanged

    - by Stephen Patten
    Hello, I'm reading the source code from the latest Prism 4 drop and am interested in solving this problem. There is a base class for the ViewModels that implements INotifyPropertyChanged and INotifyDataErrorInfo and provides some refactoring friendly change notification. protected void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpresssion) { var propertyName = ExtractPropertyName(propertyExpresssion); this.RaisePropertyChanged(propertyName); } private string ExtractPropertyName<T>(Expression<Func<T>> propertyExpresssion) { if (propertyExpresssion == null) { throw new ArgumentNullException("propertyExpression"); } var memberExpression = propertyExpresssion.Body as MemberExpression; if (memberExpression == null) { throw new ArgumentException("The expression is not a member access expression.", "propertyExpression"); } var property = memberExpression.Member as PropertyInfo; if (property == null) { throw new ArgumentException("The member access expression does not access property.","propertyExpression"); } if (!property.DeclaringType.IsAssignableFrom(this.GetType())) { throw new ArgumentException("The referenced property belongs to a different type.", "propertyExpression"); } var getMethod = property.GetGetMethod(true); if (getMethod == null) { // this shouldn't happen - the expression would reject the property before reaching this far throw new ArgumentException("The referenced property does not have a get method.", "propertyExpression"); } if (getMethod.IsStatic) { throw new ArgumentException("The referenced property is a static property.", "propertyExpression"); } return memberExpression.Member.Name; } and as an example of it's usage private void RetrieveNewQuestionnaire() { this.Questions.Clear(); var template = this.questionnaireService.GetQuestionnaireTemplate(); this.questionnaire = new Questionnaire(template); foreach (var question in this.questionnaire.Questions) { this.Questions.Add(this.CreateQuestionViewModel(question)); } this.RaisePropertyChanged(() => this.Name); this.RaisePropertyChanged(() => this.UnansweredQuestions); this.RaisePropertyChanged(() => this.TotalQuestions); this.RaisePropertyChanged(() => this.CanSubmit); } My question is this. What would it take to pass an array of the property names to an overloaded method (RaisePropertyChanged) and condense this last bit of code from 4 lines to 1? Thank you, Stephen

    Read the article

  • WPF - Setting ComboBox.SelectedItem in XAML based on matching object

    - by Andy T
    Hi, so, I have templated combobox that is basically acting as a simple colour palette. It is populated with a list of SolidColorBrush objects. Fine. Now, I have some data that holds the hex value of the current colour. I have a converter that converts the hex into a SolidColorBrush. Also fine. Now, I want to set the SelectedItem property of the combobox based on the colour from my datasource. Since my combo is populated with objects of type SolidColourBrush, and my binding converter is returning a SolidColorBrush, I assumed it would be as simple as saying: SelectedItem="{Binding Color, Converter={StaticResource StringToBrush}}" However... it doesn't work :( I've tested that the binding is working behind the scenes by using the exact same value for the Background property of the combobox. It works fine. So, clearly I can't just say SelectedItem = [something] where that [something] is basically an object equal to the item I want to be selected. What is the right way to do this? Surely it's possible in a XAML-only styley using binding, and I don't have to do some nasty C# iterating through all items in the combobox trying to find a match (that seems awfully old-school)...? Any help appreciated. Many thanks! AT

    Read the article

  • DateTime Property not firing PropertyChanged event when changed

    - by Brent
    I'm working on a WPF MVVM application and I've got a TextBox on my view that is bound to a DateTime property on the ViewModel. Seems simple enough, but when I clear the text in the TextBox, the property never changes. In fact, it never even fires until I begin typing "4/1..." and then it fires. What can I do to fix this? Obviously I could bind the TextBox to a string property and then update the real property in the setter, but that's a bit of a hack. There's got to be a better way... ViewModel private DateTime _startDate; public DateTime StartDate { get { return _startDate; } set { _startDate = value; OnPropertyChanged("StartDate"); } } View <TextBox Text="{Binding Path=StartDate, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=true}"/>

    Read the article

  • Binding Source suspends itself when I don't want it to.

    - by Scott Chamberlain
    I have two data tables set up in a Master-Details configuration with a relation "Ticket_CallSegments" between them. I also have two Binding Sources and a Data Grid View configured like this (Init Code) // // dgvTickets // this.dgvTickets.AllowUserToAddRows = false; this.dgvTickets.AllowUserToDeleteRows = false; this.dgvTickets.AllowUserToResizeRows = false; this.dgvTickets.AutoGenerateColumns = false; this.dgvTickets.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvTickets.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.cREATEDATEDataGridViewTextBoxColumn, this.contactFullNameDataGridViewTextBoxColumn, this.pARTIALNOTEDataGridViewTextBoxColumn}); this.dgvTickets.DataSource = this.ticketsDataSetBindingSource; this.dgvTickets.Dock = System.Windows.Forms.DockStyle.Fill; this.dgvTickets.Location = new System.Drawing.Point(0, 0); this.dgvTickets.MultiSelect = false; this.dgvTickets.Name = "dgvTickets"; this.dgvTickets.ReadOnly = true; this.dgvTickets.RowHeadersVisible = false; this.dgvTickets.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgvTickets.Size = new System.Drawing.Size(359, 600); this.dgvTickets.TabIndex = 0; // // ticketsDataSetBindingSource // this.ticketsDataSetBindingSource.DataMember = "Ticket"; this.ticketsDataSetBindingSource.DataSource = this.ticketsDataSet; this.ticketsDataSetBindingSource.CurrentChanged += new System.EventHandler(this.ticketsDataSetBindingSource_CurrentChanged); // // callSegementBindingSource // this.callSegementBindingSource.DataMember = "Ticket_CallSegments"; this.callSegementBindingSource.DataSource = this.ticketsDataSetBindingSource; this.callSegementBindingSource.Sort = "CreateDate"; //Function to update a rich text box. private void ticketsDataSetBindingSource_CurrentChanged(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); rtbTickets.Clear(); foreach (DataRowView drv in callSegementBindingSource) { TicketsDataSet.CallSegmentsRow row = (TicketsDataSet.CallSegmentsRow)drv.Row; sb.AppendLine("**********************************"); sb.AppendLine(String.Format("CreateDate: {1}, Created by: {0}", row.USERNAME, row.CREATEDATE)); sb.AppendLine("**********************************"); rtbTickets.SelectionFont = new Font("Arial", (float)11, FontStyle.Bold); rtbTickets.SelectedText = sb.ToString(); rtbTickets.SelectionFont = new Font("Arial", (float)11, FontStyle.Regular); rtbTickets.SelectedText = row.NOTES + "\n\n"; } } However when ticketsDataSetBindingSource_CurrentChanged gets called when I select a new row in my Data Grid View callSegementBindingSource.IsBindingSuspended is set to true and my text box does not update correctly (it seems to always pull from the same row in CallSegments). Can anyone see what I am doing wrong or tell me how to unsuspend the binding so it will pull the correct data?

    Read the article

  • ViewModel updates after Model server roundtrip

    - by Pavel Savara
    I have stateless services and anemic domain objects on server side. Model between server and client is POCO DTO. The client should become MVVM. The model could be graph of about 100 instances of 20 different classes. The client editor contains diverse tab-pages all of them live-connected to model/viewmodel. My problem is how to propagate changes after server round-trip nice way. It's quite easy to propagate changes from ViewModel to DTO. For way back it would be possible to throw away old DTO and replace it whole with new one, but it will cause lot of redrawing for lists/DataTemplates. I could gather the server side changes and transmit them to client side. But the names of fields changed would be domain/DTO specific, not ViewModel specific. And the mapping seems nontrivial to me. If I should do it imperative way after round-trip, it would break SOC/modularity of viewModels. I'm thinking about some kind of mapping rule engine, something like automappper or emit mapper. But it solves just very plain use-cases. I don't see how it would map/propagate/convert adding items to list or removal. How to identify instances in collections so it could merge values to existing instances. As well it should propagate validation/error info. Maybe I should implement INotifyPropertyChanged on DTO and try to replay server side events on it ? And then bind ViewModel to it ? Would binding solve the problems with collection merges nice way ? Is EventAgregator from PRISM useful for that ? Is there any event record-replay component ? Is there better client side pattern for architecture with server side logic ?

    Read the article

  • Two-way data binding of controls in a user control inside a FormView

    - by Sandor Drieënhuizen
    I'm trying to perform two-way data binding on the controls in my user control, which is hosted inside a FormView template. FormView: <asp:ObjectDataSource runat="server" ID="ObjectDataSource" TypeName="WebApplication1.Data" SelectMethod="GetItem" UpdateMethod="UpdateItem"> </asp:ObjectDataSource> <asp:FormView runat="server" ID="FormView"> <ItemTemplate> <uc:WebUserControl1 runat="server"></uc:WebUserControl1> </ItemTemplate> <EditItemTemplate> <uc:WebUserControl1 runat="server"></uc:WebUserControl1> </EditItemTemplate> </asp:FormView> User control: <%@ Control Language="C#" ... %> <asp:TextBox runat="server" ID="TitleTextBox" Text='<%# Bind("Title") %>'> </asp:TextBox> The binding works fine when the FormView is in View mode but when I switch to Edit mode, upon calling UpdateItem on the FormView, the bindings are lost. I know this because the FormView tries to call an update method on the ObjectDataSource that does not have an argument called 'Title'. I tried to solve this by implementing IBindableTemplate to load the controls that are inside my user control, directly into the templates (just like I had entered them declaratively like in the code above). However, when calling UpdateItem in edit mode, the container that gets passed into the ExtractValues method of the template, does not contain the TextBox anymore. It did in view mode! I have found some questions on SO that relate to this problem but they are rather dated and don't provide straight forward answers. How do you think I could solve this problem? It seems to be such a simple requirement but apparently it's more like opening a can of worms...

    Read the article

  • Trouble with LINQ databind to GridView and RowDataBound

    - by Michael
    Greetings all, I am working on redesigning my personal Web site using VS 2008 and have chosen to use LINQ to create by data-access layer. Part of my site will be a little app to help manage my budget better. My first LINQ query does successfully execute and display in a GridView, but when I try to use a RowDataBound event to work with the results and refine them a bit, I get the error: The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?) This interesting part is, if I just try to put in a var s = "s"; anywhere else in the same file, I get the same error too. If I go to other files in the web project, var s = "s"; compiles fine. Here is the LINQ Query call: public static IQueryable pubGetRecentTransactions(int param_accountid) { clsDataContext db; db = new clsDataContext(); var query = from d in db.tblMoneyTransactions join p in db.tblMoneyTransactions on d.iParentTransID equals p.iTransID into dp from p in dp.DefaultIfEmpty() where d.iAccountID == param_accountid orderby d.dtTransDate descending, d.iTransID ascending select new { d.iTransID, d.dtTransDate, sTransDesc = p != null ? p.sTransDesc : d.sTransDesc, d.sTransMemo, d.mTransAmt, d.iCheckNum, d.iParentTransID, d.iReconciled, d.bIsTransfer }; return query; } protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this.prvLoadData(); } } internal void prvLoadData() { prvCtlGridTransactions.DataSource = clsMoneyTransactions.pubGetRecentTransactions(2); prvCtlGridTransactions.DataBind(); } protected void prvCtlGridTransactions_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var datarow = e.Row.DataItem; var s = "s"; e.Row.Cells[0].Text = datarow.dtTransDate.ToShortDateString(); e.Row.Cells[1].Text = datarow.sTransDesc; e.Row.Cells[2].Text = datarow.mTransAmt.ToString("c"); e.Row.Cells[3].Text = datarow.iReconciled.ToString(); }//end if }//end RowDataBound My googling to date hasn't found a good answer, so I turn it over to this trusted community. I appreciate your time in assisting me.

    Read the article

  • Bind NameValueCollection to GridView?

    - by Xabatcha
    What kind of collection I should use to convert NameValue collection to be bindable to GridView? When doing directly it didn't work. Code in aspx.cs private void BindList(NameValueCollection nvpList) { resultGV.DataSource = list; resultGV.DataBind(); } Code in aspx <asp:GridView ID="resultGV" runat="server" AutoGenerateColumns="False" Width="100%"> <Columns> <asp:BoundField DataField="Key" HeaderText="Key" /> <asp:BoundField DataField="Value" HeaderText="Value" /> </Columns> </asp:GridView> Any tip most welcome. Thanks. X.

    Read the article

  • Modify a ListBox's item from a button in it's template?

    - by Maciek
    In my Silv erlight 3 project, I'm using a ListBox to display results of a Get() operation form a WCF WebService. The ListBox's item template is the following : <ListBox x:Name="m_listview" ItemsSource="{Binding Users, Mode=TwoWay, UpdateSourceTrigger=Default}" Foreground="{StaticResource EnergyBlue}" Background="{StaticResource EnergyBackground}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Center" Grid.ColumnSpan="3" Margin="0,0,0,2" IsSynchronizedWithCurrentItem="False"> <ListBox.ItemTemplate> <DataTemplate> <Grid MinWidth="536" MinHeight="10" d:DesignWidth="19.875" d:DesignHeight="20.75"> <Grid.ColumnDefinitions> <ColumnDefinition Width="0.2*"/> <ColumnDefinition Width="0.2*"/> <ColumnDefinition Width="0.2*"/> <ColumnDefinition Width="0.2*"/> <ColumnDefinition Width="0.2*"/> </Grid.ColumnDefinitions> <TextBox Text="{Binding Path=UserName, Mode=TwoWay, UpdateSourceTrigger=Default}" Grid.Column="0" Foreground="{StaticResource EnergyWhite}" Margin="2" Background="{StaticResource EnergyBackground}" BorderBrush="{StaticResource EnergyBlue}" SelectionBackground="{StaticResource EnergyBlue}" SelectionForeground="{StaticResource EnergyWhite}" MinWidth="100"/> <PasswordBox Password="{Binding Path=UserPass, Mode=TwoWay, UpdateSourceTrigger=Default}" Grid.Column="1" Foreground="{StaticResource EnergyWhite}" Margin="2" Background="{StaticResource EnergyBackground}" BorderBrush="{StaticResource EnergyBlue}" SelectionBackground="{StaticResource EnergyBlue}" SelectionForeground="{StaticResource EnergyWhite}" MinWidth="100"/> <TextBox Text="{Binding Path=UserTypeId, Mode=TwoWay, UpdateSourceTrigger=Default}" Grid.Column="2" Foreground="{StaticResource EnergyWhite}" Margin="2" Background="{StaticResource EnergyBackground}" BorderBrush="{StaticResource EnergyBlue}" SelectionBackground="{StaticResource EnergyBlue}" SelectionForeground="{StaticResource EnergyWhite}" MinWidth="100"/> <Button Style="{StaticResource EnergyGlassButton}" Grid.Column="3" MinWidth="10" MinHeight="10" Content="Update" Click="OnUpdateUser"/> <Button Style="{StaticResource EnergyGlassButton}" Grid.Column="4" MinWidth="10" MinHeight="10" Content="Remove" Click="OnRemoveUser"/> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> The template contains 2 buttons. When I click either of them, I'd like to obtain a reference to the exact data-item under the listboxitem. How do I do that? I've tried : User target_user = m_listview.SelectedItem as User; but it turned out that the listview item wasn't selected. Can it be done without actually selecting the listview item? For instance, just click on the "remove" button and have the row disappear? Best regards

    Read the article

  • Winform BindingSources - Question

    - by Stephen Patten
    I have a windows form (net 2.0) with controls on it bound to an entity (w/ INotifyPropertyChanged) through a BindingSource..works. On the same form I have a drop down list that is also wired up through a BindingSource..works Here's a sample of the relevant code: m_PlanItemLookupBindingSource.DataSource = GetBusinessLogic().RetrievePaymentPlanLookups(); // Collection of PaymentPlans paymentPlanType.Properties.DataSource = m_PlanItemLookupBindingSource; paymentPlanType.Properties.DisplayMember = "Name"; paymentPlanType.Properties.ValueMember = "ID"; paymentPlanType.DataBindings.Add(new Binding("EditValue", m_PlanBindingSource, "PaymentPlanID", true, DataSourceUpdateMode.OnPropertyChanged, null, "D")); agencyComission.DataBindings.Add(new Binding("EditValue", m_PlanBindingSource, "AgencyCommission", true, DataSourceUpdateMode.OnPropertyChanged, null, "P1")); billingType.DataBindings.Add(new Binding("Text", m_PlanBindingSource, "BillingType")); So when I change a value in the drop down list I thought that the m_PlanItemLookupBindingSource Current property would change along with the PaymentPlanID property of the entity which does change. Just a bit confused. Thanks in advance, Stephen

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >