Search Results

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

Page 2/35 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • WPF designer gives exception when databinding a label to a checkbox

    - by John
    I'm sure it's something stupid, but I'm playing around with databinding. I have a checkbox and a label on a form. What I'm trying to do is simply bind the Content of the label to the checkbox's IsChecked value. What I've done runs fine (no compilation errors and acts as expected), but if I touch the label in the XAML, the designer trows an exception: System.NullReferenceException Object reference not set to an instance of an object. at MS.Internal.Designer.PropertyEditing.Editors.MarkupExtensionInlineEditorControl.BuildBindingString(Boolean modeSupported, PropertyEntry propertyEntry) at <Window x:Class="UnitTestHelper.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:FileSysCtls="clr-namespace:WPFFileSystemUserControls;assembly=WPFFileSystemUserControls" xmlns:HelperClasses="clr-namespace:UnitTestHelper" Title="MainWindow" Height="406" Width="531"> <Window.Resources> <HelperClasses:ThreestateToBinary x:Key="CheckConverter" /> </Window.Resources> <Grid Height="367" Width="509"> <CheckBox Content="Step into subfolders" Height="16" HorizontalAlignment="Left" Margin="17,254,0,0" Name="chkSubfolders" VerticalAlignment="Top" Width="130" IsThreeState="False" /> <Label Height="28" HorizontalAlignment="Left" Margin="376,254,0,0" Name="lblStepResult" VerticalAlignment="Top" Width="120" IsEnabled="True" Content="{Binding IsChecked, ElementName=chkSubfolders, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource CheckConverter}}" /> </Grid> The ThreeStateToBinary class is as follows: class ThreestateToBinary : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((bool)value) return "Checked"; else return "Not checked"; //throw new NotImplementedException(); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return ((string)value == "Checked"); //throw new NotImplementedException(); } #endregion } Quite honestly, I'm playing around with it at this point. It was originally simpler (not using the ValueConverter) but was displaying similar behavior when I simply had the content set to: Content="{Binding IsChecked, ElementName=chkSubfolders, UpdateSourceTrigger=PropertyChanged}" Any ideas? Thanks, John

    Read the article

  • Databinding between 2 Dependency Properties

    - by stefan.at.wpf
    Hello, I'm trying to do databinding between 2 Dependency Properties. I guess this should be quite easy, anyways I just don't get it. I already googled but I couldn't really find out what I'm doing wrong. I'm trying to bind the ControlPointProperty to the QuadraticBezierSegment.Point1Property, however it doesn't work. Thanks for any hint! class DataBindingTest : DependencyObject { // Dependency Property public static readonly DependencyProperty ControlPointProperty; // .NET wrapper public Point ControlPoint { get { return (Point)GetValue(DataBindingTest.ControlPointProperty); } set { SetValue(DataBindingTest.ControlPointProperty, value); } } // Register Dependency Property static DataBindingTest() { DataBindingTest.ControlPointProperty = DependencyProperty.Register("ControlPoint", typeof(Point), typeof(DataBindingTest)); } public DataBindingTest() { QuadraticBezierSegment bezier = new QuadraticBezierSegment(); // Binding Binding myBinding = new Binding(); myBinding.Source = ControlPointProperty; BindingOperations.SetBinding(bezier, QuadraticBezierSegment.Point1Property, myBinding); // Test Binding: Change the binding source ControlPoint = new Point(1, 1); MessageBox.Show(bezier.Point1.ToString()); // gives (0,0), should be (1,1) } }

    Read the article

  • DataBinding the AJAX Control Toolkit's Rating Control

    - by Nevada
    I'm attempting to use the AJAX Control Toolkit's Rating control in a DataBinding scenario. I have a ReuseRating column in my database that is a tinyint. It can hold values 1 through 5. Every record in the table has the value set to 1 currently. If I do this in my ItemTemplate everything works fine. I get 1 star filled in on my rating control. <act:Rating ID="ReuseRatingRating" runat="server" CurrentRating='<%# Convert.ToInt16(Eval("ReuseRating")) %>' MaxRating="5" StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" /> Now I want to DataBind this in my EditTemplate like so. <act:Rating ID="ReuseRatingRating" runat="server" CurrentRating='<%# Convert.ToInt16(Bind("ReuseRating")) %>' MaxRating="5" StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" /> Note, that I changed my Eval to a Bind in the CurrentRating property. This throws the following error. CS0103: The name 'Bind' does not exist in the current context Can anyone help me out on this one? I've been knocking my head against the wall for a couple of hours now.

    Read the article

  • Silverlight databinding error

    - by Petezah
    I found an example online that explains how to perform databinding to a ListBox control using LINQ in WPF. The example works fine but when I replicate the same code in Silverlight it doesn't work. Is there a fundamental difference between Silverlight and WPF that I'm not aware of? Here is an Example of the XAML: <ListBox x:Name="listBox1"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" FontSize="18"/> <TextBlock Text="{Binding Role}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Here is an example of my code behind: private void UserControl_Loaded(object sender, RoutedEventArgs e) { string[] names = new string[] { "Captain Avatar", "Derek Wildstar", "Queen Starsha" }; string[] roles = new string[] { "Hero", "Captain", "Queen of Iscandar" }; listBox1.ItemSource = from n in names from r in roles select new { Name = n, Role = r} }

    Read the article

  • WPF DataBinding to standard CLR properties in code-behind

    - by nukefusion
    Hi everyone, Just learning WPF databinding and have a gap in my understanding. I've seen a few similar questions on StackOverflow, but I'm still struggling in determining what I have done wrong. I have a simple Person class with a Firstname and Surname property (standard CLR properties). I also have a standard CLR property on my Window class that exposes an instance of Person. I've then got some XAML, with two methods of binding. The first works, the second doesn't. Can anybody help me to understand why the second method fails? There's no binding error message in the Output log. <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication1" Title="Window1" Height="300" Width="300" DataContext="{Binding RelativeSource={RelativeSource Self}, Path=MyPerson}"> <StackPanel> <Label>My Person</Label> <WrapPanel> <Label>First Name:</Label> <Label Content="{Binding RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, Path=MyPerson.FirstName}"></Label> </WrapPanel> <WrapPanel> <Label>Last Name:</Label> <Label Content="{Binding MyPerson.Surname}"></Label> </WrapPanel> </StackPanel> Edit: Ok, thanks so far. I've changed the second expression to: <Label Content="{Binding Surname}"></Label> I still can't get it to work though!

    Read the article

  • Databinding Textbox to Form.Text (title)

    - by MysticEarth
    I'm trying to bind a Textbox.Text to Form.Text (which sets the title of the form). The binding itself works. But, the title isn't updated until I move the entire form. How can I achieve Form.Text being updated without moving the form? I'd like Form.Text being updated directly when I type something in the Textbox. Edit; I set the title of the Form in a TextChanged event which is fired by a ToolStripTextbox: public partial class ProjectForm : Form { public ProjectForm() { // my code contains all sorts of code here, // but nothing that has something to do with the text. } } private void projectName_TextChanged_1(object sender, EventArgs e) { this.Text = projectName.TextBox.Text; } And the Databinding version: public partial class ProjectForm : Form { public ProjectForm() { this.projectName.TextBox.DataBindings.Add("Text", this, "Text", true, DataSourceUpdateMode.OnValidation); } } Edit 2: I see I forgot to mention something. Don't know if it adds anything, but my apllication is a MDI application. The part of the title that changes is: ApplicationName [THIS CHANGES, BUT ONLY AFTER MOVING/RESIZING]

    Read the article

  • Databinding to the DataGridView (Enums + Collections)

    - by Ian
    I'm after a little help with the techniques to use for Databinding. It's been quite a while since I used any proper data binding and want to try and do something with the DataGridView. I'm trying to configure as much as possible so that I can simply designed the DatagridView through the form editor, and then use a custom class that exposes all my information. The sort of information I've got is as follows: public class Result { public String Name { get; set; } public Boolean PK { get; set; } public MyEnum EnumValue { get; set; } public IList<ResultInfos> { get; set; } } public class ResultInfos { get; set; } { public class Name { get; set; } public Int Value { get; set; } public override String ToString() { return Name + " : " Value.ToString(); } } I can bind to the simple information without any problem. I want to bind to the EnumValue with a DataGridViewComboBoxColumn, but when I set the DataPropertyName I get exceptions saying the enum values aren't valid. Then comes the ResultInfo collection. Currently I can't figure out how to bind to this and display my items, again really I want this to be a combobox, where the 1st Item is selected. Anyone any suggestions on what I'm doing wrong? Thanks

    Read the article

  • Custom UserControl property not being set via XAML DataBinding in Silverlight 4

    - by programatique
    I have a custom user control called GoalProgressControl. Another user control contains GoalProgressControl and sets its GoalName attribute via databinding in XAML. However, the GoalName property is never set. When I check it in debug mode GoalName remains "null" for the control's lifetime. How do I set the GoalName property? Is there something I am doing incorrectly? I am using .NET Framework 4 and Silverlight 4. I am relatively new to XAML and Silverlight so any help would be greatly appreciated. I have attempted to change GoalProgressControl.GoalName into a POCO property but this causes a Silverlight error, and my reading leads me to believe that databound properties should be of type DependencyProperty. I've also simplified my code to just focus on the GoalName property (the code is below) with no success. Here is GoalProgressControl.xaml: <UserControl x:Class="GoalView.GoalProgressControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding RelativeSource={RelativeSource Self}}" Height="100"> <Border Margin="5" Padding="5" BorderBrush="#999" BorderThickness="1"> <TextBlock Text="{Binding GoalName}"/> </Border> </UserControl> GoalProgressControl.xaml.cs: public partial class GoalProgressControl : UserControl, INotifyPropertyChanged { public GoalProgressControl() { InitializeComponent(); } public event PropertyChangedEventHandler PropertyChanged; public void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public static DependencyProperty GoalNameProperty = DependencyProperty.Register("GoalName", typeof(string), typeof(GoalProgressControl), null); public string GoalName { get { return (String)GetValue(GoalProgressControl.GoalNameProperty); } set { base.SetValue(GoalProgressControl.GoalNameProperty, value); NotifyPropertyChanged("GoalName"); } } } I've placed GoalProgressControl on another page: <Grid Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="5" Background="#eee" Height="200"> <Border BorderBrush="#999" BorderThickness="1" Background="White"> <StackPanel> <hgc:SectionTitleBar x:Name="ttlGoals" Title="Personal Goals" ImageSource="../Images/check.png" Uri="/Pages/GoalPage.xaml" MoreVisibility="Visible" /> <ItemsControl ItemsSource="{Binding Path=GoalItems}"> <ItemsControl.ItemTemplate> <DataTemplate> <!--TextBlock Text="{Binding Path=[Name]}"/--> <goal:GoalProgressControl GoalName="{Binding Path=[Name]}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </StackPanel> </Border> </Grid> Please note the commented out "TextBlock" item above. If I comment in the TextBlock and comment out the GoalProgressControl, the binding works correctly and the TextBlock shows the GoalName correctly. Also, if I replace the "GoalName" property above with a simple text string (ex "hello world"), the control renders correctly and "hello world" is shown on the control when it renders.

    Read the article

  • Usercontrol databinding within a databound datagridview

    - by user328259
    Good day. I'm developing a Windows application and working with Windows Forms; .Net 2.0. I have an issue databinding a generic List of Car Rental Companies to a DataGridView when that list contains (one of its properties) anoother generic List of Car Makes. I also have a UserControl that I need to bind to this [inner] generic list ... Class CarRentalCompany contains: string Name, string Location, List CarMakes Class CarMake contains: string Name, bool isFord, bool isChevy, bool isOther The UserControl has a label for CarMake.Name and 3 checkboxes for each of the booleans of the class. HOw do I make this user control bindable for the class? In my form, I have a DataGridView binded to the CarRentalCompany object. The list CarMakes could be 0 or more items and I can add these as necessary. How do I establish the binding of CarRentalCompanies properly so CarMakes will bind accordingly?? For example, I have: List CarRentalCompanies = new List(); CarRentalCompany company1 = new CarRentalCompany(); company1.Name = "Acme Rentals"; company1.Location = "New York, NY"; company1.CarMakes = new List<CarMake>(); CarMake car1 = new CarMake(); car1.Name = "The Yellow Car"; car1.isFord = true; car1.isChevy = false; car1.isOther = false; company1.CarMakes.Add(car1); CarMake car2 = new CarMake(); car2.Name = "The Blue Car"; car2.isFord = false; car2.isChevy = true; car2.isOther = false; company1.CarMakes.Add(car2); CarMake car3 = new CarMake(); car3.Name = "The Purple Car"; car3.isFord = false; car3.isChevy = false; car3.isOther = true; company1.CarMakes.Add(car3); CarRentalCompanies.Add(company1); CarRentalCompany company2 = new CarRentalCompany(); company1.Name = "Z-Auto Rentals"; company1.Location = "Phoenix, AZ"; company1.CarMakes = new List<CarMake>(); CarMake car4 = new CarMake(); car4.Name = "The OrangeCar"; car4.isFord = true; car4.isChevy = false; car4.isOther = false; company2.CarMakes.Add(car4); CarMake car5 = new CarMake(); car5.Name = "The Red Car"; car5.isFord = true; car5.isChevy = false; car5.isOther = false; company2.CarMakes.Add(car5); CarMake car6 = new CarMake(); car6.Name = "The Green Car"; car6.isFord = true; car6.isChevy = false; car6.isOther = false; company2.CarMakes.Add(car6); CarRentalCompanies.Add(company2); I load my form and in my load form I have the following: Note: CarDataGrid is a DataGridView BindingSource bsTheRentals = new BindingSource(); DataGridViewTextBoxColumn companyName = new DataGridViewTextBoxColumn(); companyName.DataPropertyName = "Name"; companyName.HeaderText = "Company Name"; companyName.Name = "CompanyName"; companyName.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DataGridViewTextBoxColumn companyLocation = new DataGridViewTextBoxColumn(); companyLocation.DataPropertyName = "Location"; companyLocation.HeaderText = "Company Location"; companyLocation.Name = "CompanyLocation"; companyLocation.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; ArrayList carMakeColumnsToAdd = new ArrayList(); // Loop through the CarMakes list to add each custom column for (int intX=0; intX < CarRentalCompanies.CarMakes[0].Count; intX++) { // Custom column for user control string carMakeColumnName = "carColumn" + intX; CarMakeListColumn carMakeColumn = new DataGridViewComboBoxColumn(); carMakeColumn.Name = carMakeColumnName; carMakeColumn.DisplayMember = CarRentalCompanies.CarMakes[intX].Name; carMakeColumn.DataSource = CarRentalCompanies.CarMakes; // this is the CarMAkes List carMakeColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; carMakeColumnsToAdd.Add(carMakeColumn); } CarDataGrid.DataSource = bsTheRentals; CarDataGrid.Columns.AddRange(new DataGridViewColumn[] { companyName, companylocation, carMakeColumnsToAdd }); CarDataGrid.AutoGenerateColumns = false; The code I provided does not work because I am unfamiliar with UserControls and custom DataGridViewColumns and DataGridViewCells - I know I must derive from these classes in order to use my User Control properly. I appreciate any advice/assistance/help in this. Thank you. Lawrence

    Read the article

  • WPF TreeView databinding to hide/show expand/collapse icon

    - by Julian Lettner
    I implemented a WPF load-on-demand treeview like described in this (very good) article. In the mentioned solution a dummy element is used to preserve the expand + icon / treeview item behavior. The dummy item is replaced with real data, when the user clicks on the expander. I want to refine the model by adding a property public bool HasChildren { get { ... } } to my backing TreeNodeViewModel. Question: How can I bind this property to hide/show the expand icon (in XAML)? I am not able to find a suitable trigger/setter combination. (INotifyPropertyChanged is properly implemented.) Thanks for your time. Update 1: I want to use my property public bool HasChildren instead of using the dummy element. Determining whether or not an item has children is somewhat costly, but still much cheaper than fetching the children.

    Read the article

  • DataBinding a dictionary to a combobox in WPF.

    - by Ashish Ashu
    I have a Dictionary which is binded to a combobox. I have used dictionary to provide spaces in enum. public enum Option {Enter_Value, Select_Value}; Dictionary<Option,string> Options; <ComboBox x:Name="optionComboBox" SelectionChanged="optionComboBox_SelectionChanged" SelectedValuePath="Key" DisplayMemberPath="Value" SelectedItem="{Binding Path = SelectedOption}" ItemsSource="{Binding Path = Options}" /> This works fine. My queries: 1. I am not able to set the initial value to a combo box. In above XAML snippet the line SelectedItem="{Binding Path = SelectedOption}" is not working. I have declared SelectOption in my viewmodel. This is of type string and I have intialized this string value in my view model as below: SelectedOption = Options[Options.Enter_Value].ToString(); 2. I want if user selects Options.Enter_Value from the combo box , the combo box becomes editable and user can enter the numeric value in it. If user selects the second option Options.Select_Value then a dialog is poped up which allows user to select the predifined values. And the combo box becomes read only and shows the selected value. Please Help!!

    Read the article

  • winforms databinding best practices

    - by Kaiser Soze
    Demands / problems: I would like to bind multiple properties of an entity to controls in a form. Some of which are read only from time to time (according to business logic). When using an entity that implements INotifyPropertyChanged as the DataSource, every change notification refreshes all the controls bound to that data source (easy to verify - just bind two properties to two controls and invoke a change notification on one of them, you will see that both properties are hit and reevaluated). There should be user friendly error notifications (the entity implements IDataErrorInfo). (probably using ErrorProvider) Using the entity as the DataSource of the controls leads to performance issues and makes life harder when its time for a control to be read only. I thought of creating some kind of wrapper that holds the entity and a specific property so that each control would be bound to a different DataSource. Moreover, that wrapper could hold the ReadOnly indicator for that property so the control would be bound directly to that value. The wrapper could look like this: interface IPropertyWrapper : INotifyPropertyChanged, IDataErrorInfo { object Value { get; set; } bool IsReadOnly { get; } } But this means also a different ErrorProvider for each property (property wrapper) I feel like I'm trying to reinvent the wheel... What is the 'proper' way of handling complex binding demands like these? Thanks ahead.

    Read the article

  • WPF Databinding thread safety?

    - by Petoj
    Well lets say i have an object that i databind to, it implements INotifyPropertyChanged to tell the GUI when a value has changed... if i trigger this from a different thread than the GUI thread how would wpf behave? and will it make sure that it gets the value of the property from memory and not the cpu cache? more or less im asking if wpf does lock() on the object containing the property...

    Read the article

  • Silverlight 4, combobox databinding problem

    - by synergetic
    In my Silverlight 4 app, CustomerView (UserControl) shows Customer object as it's DataContext. Customer object has IndustryCode string property. I created combobox called cboIndustryCode and bind it to the IndustryCode property the following way: <ComboBox x:Name="cboIndustryCode" SelectedValue="{Binding IndustryCode, Mode=TwoWay}" ... /> In code-behind I populate cboIndustryCode with List of Industry object, which has Code and Name properties: cboIndustryCode.ItemsSource = industries; //which is of List<Industry> type Now, to show everything properly, in XAML I added the following: <ComboBox x:Name="cboIndustryCode" SelectedValue="{Binding IndustryCode, Mode=TwoWay}" DisplayMemberPath="Name" SelectedValuePath="Code" ... /> So, when I get a customer class from my data layer and set the DataContext to this customer instance, the cboIndustryCode properly displays industry name. But, then I edit customer (not necessarily IndustryCode) and save the object (which resets DataContext = new Customer()) and retrieve the customer again from database, and I see that cboIndustryCode no longer working. It just displays nothing, and if I select new value from the list, it does not update underlying customer object's IndustryCode property. The problem goes away, if I put the following code in the place where I set DataContext to a instance of customer, retrieved from database: Binding binding = new Binding("IndustryCode"); binding.Mode = BindingMode.TwoWay; cboIndustryCode.SetBinding(ComboBox.SelectedValueProperty, binding); So, in short, combobox's binding is reset somehow every time I save my data. Can someone tell me the reason?

    Read the article

  • Databinding a ListBox with SelectionMode = Multiple

    - by David Veeneman
    I have a WPF ListBox that I would like to Enable multiple selection in the ListBox, and Databind the ListBox to my view model. These two requirements appear to be incompatible. My view model has an ObservableCollection<T> property to bind to this ListBox; I set up a binding in XAML from the property to the ListBox.SelectedItems property. When I compiled, I got an error saying that the SelectedItems property was read only and could not be set from XAML. Am I binding to the wrong control property? Is there a way to bind a multiple-selection ListBox in XAML to a view model collection property? Thanks for your help.

    Read the article

  • DataGridView's SelectionChange event firing twice on DataBinding even after removing event binding

    - by Shantanu Gupta
    This Code triggers selection change event twice. how can I prevent it ? Currently i m using a flag or focused property to prevent this. But what is the actual way ? I am using it on winfoms EDIT My Mistake in writing Question, here is the correct code that i wanted to ask private void frmGuestInfo_Load(object sender, EventArgs e) { this.dgvGuestInfo.SelectionChanged -= new System.EventHandler(this.dgvGuestInfo_SelectionChanged); dgvGuestInfo.DataSource=dsFillControls.Tables["tblName"]; this.dgvGuestInfo.SelectionChanged += new System.EventHandler(this.dgvGuestInfo_SelectionChanged); } private void dgvGuestInfo_SelectionChanged(object sender, EventArgs e) { //this function is raised twice, i was expecting that this will not be raised }

    Read the article

  • ASP.Net menu databinding encoding problem

    - by WtFudgE
    Hi, I have a menu where I bind data through: XmlDataSource xmlData = new XmlDataSource(); xmlData.DataFile = String.Format(@"{0}{1}\Navigation.xml", getXmlPath(), getLanguage()); xmlData.XPath = @"/Items/Item"; TopNavigation.DataSource = xmlData; TopNavigation.DataBind(); The problem is when my xml has special characters, since I use a lot of french words. As an alternative I tried using a stream instead and using encoding to get the special characters, with the following code: StreamReader strm = new StreamReader(String.Format(@"{0}{1}\Navigation.xml", getXmlPath(), getLanguage()), Encoding.GetEncoding(1254)); XmlDocument xDoc = new XmlDocument(); xDoc.Load(strm); XmlDataSource xmlData = new XmlDataSource(); xmlData.ID = "TopNav"; xmlData.Data = xDoc.InnerXml; xmlData.XPath = @"/Items/Item"; TopNavigation.Items.Clear(); TopNavigation.DataSource = xmlData; TopNavigation.DataBind(); The problem I'm having now is that my data doesn't refresh when I change the path where the stream gets read. When I skip through the code it does, but not on my page. So the thing is either, how do I get the data te be refreshed? Or (which is actually preferred) how do I get the encoding right in the first piece of code? Help is highly apreciated!

    Read the article

  • EntityFramework EntityState and databinding along with INotifyPropertyChanged

    - by OffApps Cory
    Hello, all! I have a WPF view that displays a Shipment entity. I have a textblock that contains an asterisk which will alert a user that the record is changed but unsaved. I originally hoped to bind the visibility of this (with converter) to the Shipment.EntityState property. If value = EntityState.Modified Then Return Visibility.Visible Else Return Visibility.Collapsed End If The property gets updated just fine, but the view is ignorant of the change. What I need to know is, how can I get the UI to receive notification of the property change. If this cannot be done, is there a good way of writing my own IsDirty property that handles editing retractions (i.e. if I change the value of a property, then change it back to it's original it does not get counted as an edit, and state remains Unchanged). Any help, as always, will be greatly appreciated. Cory

    Read the article

  • Databinding in WinForms performing async data import

    - by burnside
    I have a scenario where I have a collection of objects bound to a datagrid in winforms. If a user drags and drops an item on to the grid, I need to add a placeholder row into the grid and kick off a lengthy async import process. I need to communicate the status of the async import process back to the UI, updating the row in the grid and have the UI remain responsive to allow the user to edit the other rows. What's the best practice for doing this? My current solution is: binding a thread safe implementation of BindingList to the grid, filled with the objects that are displayed as rows in the grid. When a user drags and drops an item on to the grid, I create a new object containing the sparse info obtained from the dropped item and add that to the BindingList, disabling the editing of that row. I then fire off a separate thread to do the import, passing it the newly bound object I have just created to fill with data. The import process, periodically sets the status of the object and fires an event which is subscribed to by the UI telling it to refresh the grid to see the new properties on the object. Should I be passing the same object that is bound to the grid to the import process thread to operate on, or should I be creating a copy and merging back the changes to the object on the UI thread using BeginInvoke? Any problems or advice with this implementation? Thanks

    Read the article

  • DataBinding in ResourceDictionary

    - by Vishal
    Hi All, I've a ResourceDictionary. In which I've defined all the commands. <ResourceDictionary x:Class="HTCmds" x:ClassModifier="public" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:commands="clr-namespace:Commands;assembly=UIInfrastructure" xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" xmlns:local="clr-namespace:Commands" xmlns:p="clr-namespace:PresentationModels"> <commands:CommandReference x:Key="CopyCommandReference" Command="{Binding Path=CopyCommand}"/> <commands:CommandReference x:Key="ExitCommandReference" Command="{Binding Path=ExitCommand}"/> </ResourceDictionary> I've merged this ResourceDictionary in a Windows class. <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="../Commands/HTCmds.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> This window class has DataContext property set to Commands.cs class that contains all the commands and their handlers. Now, How do I bind the commands defined in ResourceDictionary with commands in DataContext of Windows class? Thanks & Regards, Vishal.

    Read the article

  • Databinding items to Canvas

    - by Jo-wen
    I have a userControl that contains a canvas. I would like to databind items to it so they are positioned automagically. Here's a great example that shows how to databind items on a canvas, but I want it to work on my specific userControl. (I believe it's not possible to specify a userControl in a ItemsPanelTemplate)

    Read the article

  • DataBinding to ListView

    - by Neir0
    Hi, I have a class public class Foo { public List<string> list1 { get; set;} public List<string> list2 { get; set; } public string url; } and a ListView with two columns <ListView Name="listview" ItemsSource="{Binding}"> <ListView.View> <GridView> <GridViewColumn Header="list1" DisplayMemberBinding="{Binding Path=list1}" /> <GridViewColumn Header="list2" DisplayMemberBinding="{Binding Path=list2}" /> </GridView> </ListView.View> </ListView> How i can to bind instance of Foo class to ListView? Here i set DataContext listview.DataContext = new Foo() { list1 = new[] { "dsfasd", "asdfasdf", "asdf", "asdfasd" }.ToList(), list2 = new[] { "dsfasd", "asdfasdf", "asdf", "asdfasd" }.ToList() }; But it's not work.

    Read the article

  • Databinding gives "System.Data.DataRowView" instead of actual values

    - by iTayb
    This is my code: string SQL = "SELECT email FROM members WHERE subscribe=true"; string myConnString = Application["ConnectionString"].ToString(); OleDbConnection myConnection = new OleDbConnection(myConnString); OleDbCommand myCommand = new OleDbCommand(SQL, myConnection); myConnection.Open(); OleDbDataAdapter MyAdapter = new OleDbDataAdapter(myCommand); DataSet ds = new DataSet(); MyAdapter.Fill(ds); MailsListBox.DataSource = ds; MailsListBox.DataBind(); GridView1.DataSource = ds; GridView1.DataBind(); myConnection.Close(); And so it looks: As you see, the GridView shows the dataset just fine, and the ListBox fails it. What happened? How can I fix it? Thank you very much.

    Read the article

  • Combine master-detail databinding

    - by clawson
    I have created data sources from my objects in my project, some of which have other objects as members. When I want to bind a some objects to a data grid I would like to display some of the values from the member objects in the data grid as well but the examples I have come across seem to use an entire other datagrid or controls to display these member object values. How can I combine these values into one data grid? (Preferably without creating a wrapping class) Can I achieve this with LINQ somehow? Your help is greatly appreciated. Thanks P.S. C# or VB examples will do.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >