Search Results

Search found 30000 results on 1200 pages for '2 way object databinding'.

Page 12/1200 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Problem in databinding a dictionary in ListView combo-box column.

    - by Ashish Ashu
    I have a listview of which itemsource is set to my custom collection, let's say MyCollection. The code below is not full code , it's just a code snippets to explain the problem. class Item : INotifyPropertyChanged { Options _options; public Options OptionProp { get { return _options; } set { _options = value; OnPropertyChanged ("OptionProp");} } string _Name; public string NameProp { get { return _Name; } set { _Name = value; OnPropertyChanged ("NameProp");} } } class Options : Dictionary<string,string> { public Options() { this.Clear(); this.Add("One" , "1" ); this.Add("Two" , "2" ); this.Add("Three" , "3" ); } } MyCollection in my viewModel class viewModel { ObservableCollection<Item> **MyCollection**; KeyValuePair<sting,string> **SelectedOption**; } The listview Item Source is set to my MyCollection. <ListView ItemSource = MyCollectoin> I Listview contains two columns of which I have defined a datatemplats in the listview. First column is a combo-box of which Itemsource is set to Options ( defined above ) Second column is a simple textblock to display Name. Problem 1. I have defined a datatemplate for first column in which I have a combo box , I have set the Itemsource =**MyCollection** and SelectedItem = SelectedOption of the combo-box. User can perform following operations in the listview: Add ( Add the row in the listview ) Move Up ( Move row up in the listview ) Move Down ( Move down the item in the listview ) .Now when I add the row in the listview , the combo-box selected index is always comes to -1 (first column). However the combo box contains options One, Two and Three. Also, I have initialized the SelectedOption to contain the first item, i:e One. problem 2. . Let suppose, I have added a single row in a listview and I have selected Option "one" in the combo box manually. Now when I perform Move Up or Move Down operations the selected index of a combo box is again set to -1. In the Move Up or Move Down operation , I am calling MoveUp and MoveDown methods of the Observable collection. Probelm 3 How to serialize the entire collection in XML. Since I can't serialize the Dictionary and KeyValue Pair. I have to restore the state of the listview.

    Read the article

  • Problem in DataBinding an Enum using dictionary approach 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. The combobox is binded to datadictionary which have two options first is "Enter_value" and second is "Select_value" which is actually Option enum. Based on the Option enum value I want to perform different action. For example if option is equal to option.Enter_value then Combo box becomes editable and user can enter the numeric value in it. if option is equal to option.Select_value value then the value comes from the database and the combo box becomes read only and shows the fetched value from the database. Please Help!!

    Read the article

  • What am I doing wrong with my ItemsControl & databinding?

    - by Joel
    I'm reworking my simple hex editor to practice using what I've recently learned about data binding in WPF. I'm not sure what I'm doing wrong here. As I understand it, for each byte in the collection "backend" (inherits from ObservableCollection), my ItemsControl should apply the DataTemplate under resources. This template is just a textbox with a binding to a value converter. So I'm expecting to see a row of textboxes, each containing a string representation of one byte. When I use this XAML, all I get is a single line of uneditable text, which as far as I can tell doesn't use a textbox. What am I doing wrong? I've pasted my XAML in below, with the irrelevant parts (Menu declaration, schema, etc) removed. <Window ...> <Window.Resources> <local:Backend x:Key="backend" /> <local:ByteConverter x:Key="byteConverter" /> <DataTemplate DataType="byte"> <TextBox Text="{Binding Converter={StaticResource byteConverter}}" /> </DataTemplate> </Window.Resources> <StackPanel> <ItemsControl ItemsSource="{Binding Source={StaticResource backend}}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </StackPanel> </Window>

    Read the article

  • Is it possible to apply NOT(!) operator while DataBinding a property of a control ?

    - by Ashish Ashu
    I have Button control and I have to set the IsEanbled property based on the bool variable. bool IsBoolVariable I want if IsBoolVariable property is true then I want to set the IsEnabled property to false AND when IsBoolVariable property is false then I want to set the IsEnabled property to true. Is it possible to apply not(!) operator while defining the binding as given below <Button IsEnabled = "{Binding Path = **!**IsBoolVariable}" /> I can very well do that by applying convertors , but that is the only way to do that?

    Read the article

  • Deriving an HTMLElement Object from jQuery Object

    - by Jasconius
    I'm doing a fairly exhaustive series of DOM manipulations where a few elements (specifically form elements) have some events. I am dynamically creating (actually cloning from a source element) several boxes and assigning a change() event to them. The change event executes, and within the context of the event, "this" is the HTML Element Object. What I need to do at this point however is determine a contact for this HTML Element Object. I have these objects stored already as jQuery entities in assorted arrays, but obviously [HTMLElement Object] != [Object Object] And the trick is that I cannot cast $(this) and make a valid comparison since that would create a new object and the pointer would be different. So... I've been banging my head against this for a while. In the past I've been able to circumvent this problem by doing an innerHTML comparison, but in this case the objects I am comparing are 100% identical, just there's lots of them. Therefore I need a solid comparison. This would be easy if I could somehow derive the HTMLElement object from my originating jQuery object. Thoughts, other ideas? Help. :(

    Read the article

  • Convert JSON flattened for forms back to an object

    - by George Jempty
    I am required (please therefore no nit-picking the requirement, I've already nit-picked it, and this is the req) to convert certain form fields that have "object nesting" embedded in the field names, back to the object(s) themselves. Below are some typical form field names: phones_0_patientPhoneTypeId phones_0_phone phones_1_patientPhoneTypeId phones_1_phone The form fields above were derived from an object such as the one toward the bottom (see "Data"), and that is the format of the object I need to reassemble. It can be assumed that any form field with a name that contains the underscore _ character needs to undergo this conversion. Also that the segment of the form field between underscores, if numeric, signifies a Javascript array, otherwise an object. I found it easy to devise a (somewhat naive) implementation for the "flattening" of the original object for use by the form, but am struggling going in the other direction; below the object/data below I'm pasting my current attempt. One problem (perhaps the only one?) with it is that it does not currently properly account for array indexes, but this might be tricky because the object will subsequently be encoded as JSON, which will not account for sparse arrays. So if "phones_1" exists, but "phones_0" does not, I would nevertheless like to ensure that a slot exists for phones[0] even if that value is null. Implementations that tweak what I have begun, or are entirely different, encouraged. If interested let me know if you'd like to see my code for the "flattening" part that is working. Thanks in advance Data: var obj = { phones: [{ "patientPhoneTypeId": 4, "phone": "8005551212" }, { "patientPhoneTypeId": 2, "phone": "8885551212" }]}; Code to date: var unflattened = {}; for (var prop in values) { if (prop.indexOf('_') > -1) { var lastUnderbarPos = prop.lastIndexOf('_'); var nestedProp = prop.substr(lastUnderbarPos + 1); var nesting = prop.substr(0, lastUnderbarPos).split("_"); var nestedRef, isArray, isObject; for (var i=0, n=nesting.length; i<n; i++) { if (i===0) { nestedRef = unflattened; } if (i < (n-1)) { // not last if (/^\d+$/.test(nesting[i+1])) { isArray = true; isObject = false; } else { isArray = true; isObject = false; } var currProp = nesting[i]; if (!nestedRef[currProp]) { if (isArray) { nestedRef[currProp] = []; } else if (isObject) { nestedRef[currProp] = {}; } } nestedRef = nestedRef[currProp]; } else { nestedRef[nestedProp] = values[prop]; } } }

    Read the article

  • Using an object in an if statement... (Android)

    - by James Rattray
    I have an object variable Object test = Spinner.getSelectedItem(); -It gets the selected item from the Spinner (called spinner) and names the item 'test' I want to do an if statement related to that object e.g: 'if (test = "hello") { //do something }' But it appears not to work.... Can someone give me some help? -Do I have to use a different if? or convert the object to string etc.? Thanks alot... James

    Read the article

  • Code Contracts Vs. Object Initializers (.net 4.0)

    - by Mystagogue
    At face value, it would seem that object initializers present a problem for .net 4.0 "code contracts", where normally the invariant should be established by the time the object constructor is finished. Presumably, however, object-initializers require properties to be set after construction is complete. My question is if the invariants of "code contracts" are able to handle object initializers, "as if" the properties were set before the constructor completes? That would be very nice indeed!!

    Read the article

  • Scala passing type parameters to object

    - by Shahzad Mian
    In Scala v 2.7.7 I have a file with class Something[T] extends Other { } object Something extends OtherConstructor[Something] { } This throws the error: class Something takes type parameters object Something extends OtherConstructor[Something] { However, I can't do this object Something[T] extends OtherConstructor[Something[T]] { } It throws an error: error: ';' expected but '[' found. Is it possible to send type parameters to object? Or should I change and simply use Otherconstructor

    Read the article

  • Check if an object is defined in html

    - by Manikanta
    In HTML, I have an object tag as follows: <OBJECT ID="objectid" CLASSID="some-class-id" CODEBASE="some-codebase"> I have written a function in JavaScript to access this object. I checked the null value as follows: if(objectid==null){-----} i want to check if the object is undefined or is empty. Do we have any functions to check so?

    Read the article

  • So what *did* Alan Kay really mean by the term "object-oriented"?

    - by Charlie Flowers
    Reportedly, Alan Kay is the inventor of the term "object oriented". And he is often quoted as having said that what we call OO today is not what he meant. For example, I just found this on Google: I made up the term 'object-oriented', and I can tell you I didn't have C++ in mind -- Alan Kay, OOPSLA '97 I vaguely remember hearing something pretty insightful about what he did mean. Something along the lines of "message passing". Do you know what he meant? Can you fill in more details of what he meant and how it differs from today's common OO? Please share some references if you have any. Thanks.

    Read the article

  • Interesting Type difference in .NET 4.0 when using DataBinding

    - by Lorin Thwaits
    Consider this common construct that you and I have thrown into ASPX pages for years now: <%# DataBinder.Eval (Container.DataItem, "EmployeeID") %> In .NET 3.5.1 and older it returns -- tada -- a string.  No mystery there.  But in .NET 4.0 it returns the same type as the underlying data type -- which in this case for me was a nullable int.  Interesting, no?

    Read the article

  • Databinding a ListView with Mono for Android

    - by Wallym
    The world lives on data. Data is all around us and in many forms: salespeople need to know what customers have spent; twitter users want to know what their friends are saying. How do we as developers present data to a user? In Android, we use the ListView in its various forms. In this article, we'll look at using a ListView, how we can work with it, then discuss what we need to do to overcome some of the challenges in a mobile environment.Article url: http://visualstudiomagazine.com/articles/2012/09/14/databind-a-listview.aspx

    Read the article

  • Where, in an object oriented system should you, if at all, choose (C-style) structs over classes?

    - by Anto
    C and most likely many other languages provide a struct keyword for creating structures (or something in a similar fashion). These are (at least in C), from a simplified point of view like classes, but without polymorphism, inheritance, methods, and so on. Think of an object-oriented (or multi paradigm) language with C-style structs. Where would you choose them over classes? Now, I don't believe they are to be used with OOP as classes seem to replace their purposes, but I wonder if there are situations where they could be preferred over classes in otherwise object-oriented programs and in what kind of situations. Are there such situations?

    Read the article

  • Should I pass an object into a constructor, or instantiate in class?

    - by Prisoner
    Consider these two examples: Passing an object to a constructor class ExampleA { private $config; public function __construct($config) { $this->config = $config; } } $config = new Config; $exampleA = new ExampleA($config); Instantiating a class class ExampleB { private $config; public function __construct() { $this->config = new Config; } } $exampleA = new ExampleA(); Which is the correct way to handle adding an object as a property? When should I use one over the other? Does unit testing affect what I should use?

    Read the article

  • How to design this procedural application into object oriented format?

    - by DavidL
    I'm building an application that basically pulls json data from a bunch of websites, processes it in some way and then writes it to a file. It is very easy to write this in a procedural way. I was wondering how this could be done in an object oriented way. Currently, the application looks something like this: res = get_json(link); process(res); write(res); Even if writing this in an object oriented way is not the best idea, tell me how it could be done because I have trouble with it.

    Read the article

  • Nested function inside literal Object...

    - by Andrea
    Hello guys, if in a literal object i try to reference a function using "this" inside a nested property/function, this don't work. Why? A nested property have it's own scope? For example, i want to call f1 from inside d.f2: var object = { a: "Var a", b: "Var b", c: "Var c", f1: function() { alert("This is f1"); }, d: { f2: function() { this.f1(); } }, e: { f3: function() { alert("This is f3"); } } } object.f1(); // Work object.d.f2(); // Don't Work. object.e.f3(); // Work Thanks, Andrea.

    Read the article

  • Implementation of a general-purpose object structure (property bag)

    - by Thomas Wanner
    We need to implement some general-purpose object structure, much like an object in dynamic languages, that would give us a possibility of creating the whole object graph on-the-fly. This class has to be serializable and somehow user friendly. So far we have made some experiments with class derived from Dictionary<string, object> using the dot notation path to store properties and collections in the object tree. We have also find an article that implements something similar, but it doesn't seem to fit completely into our picture either. Do you know about some good implementations / libraries that deal with a similar problem or do you have any (non-trivial) ideas that could help us with our own implementation ? Also, I probably have to say that we are using .NET 3.5, so we can't take advantage of the new features in .NET 4.0 like dynamic type etc. (as far as I know it's also not possible to use any subset of it in .NET 3.5 solution).

    Read the article

  • stringtemplate .net dynamic object

    - by Mark Milford
    Hi I am using string template to render some content, but the content may be variable so not sure how to pass it in (using .net / c#) Basic idea is I have a List which need to end up as parameters, e.g. List<KeyValuePair<string, object>> ret = new List<KeyValuePair<string, object>>(); ret.Add(new KeyValuePair<string, object>("elem1", true)); ret.Add(new KeyValuePair(string, object>("elem2", false)); Now I want these to show up in string template as: $item.elem1$ $item.elem2$ I can get them to be $elem1$ or $elem2$ but i need them inside of a structure. So I in effect need to convince the string template setAttribute that I'm passing in an object with properties elem1 and elem2 when in fact I have a List of KeyValuePairs. Thanks

    Read the article

  • accessing embedded object with jquery not working in firefox 3.6

    - by taber
    Hi, this code in my plugin used to work just fine: jQuery('#embedded_obj', context).get(0).getVersion(); and in html... <object id="embedded_obj" type="application/x-versionchecker-1.0.0.1"</object Basically trying to get the properties from an embedded object. But it looks like get(0) is returning an html object instead of the actual embedded object. For example, if I do: var launcher = jQuery('#embedded_obj', context).get(0); for(prop in launcher){ alert(prop + ': ' + launcher[prop]); } ... it alerts things like "getElementByNode," "scrollWidth," "clientLeft," "clientTop" etc. Again this worked before Firefox 3.6. Has anyone else seen this or have any ideas/suggestions? Thanks!

    Read the article

  • differences between using wmode="transparent", "opaque", "window" for an embedded object on webpage

    - by Jian Lin
    when embedding a Flash object with the <object and <embed tag, there is an attribute called "wmode". It seems that most of the time, wmode="transparent" is the same as wmode="opaque" as the Flash doesn't actually have any transparent color so that the bottom HTML element is to be shown. As a result, "opaque" should be faster than "transparent" since it require less processing for transparency, yet most of the time i see Flash object embedded with "transparent" instead of "opaque". "opaque" is needed so that other HTML element won't be covered up by the Flash object. (such as a menu item that pops up an extra sub-menu won't be covered up by the Flash object). By the way, is there formal documentation for wmode's "opaque", "transparent", and "window"? I was only able to find blogs that describe it but not the formal documentation. thanks.

    Read the article

  • Scope of object properties & methods

    - by Anish
    In the article Show love to the object literal, it's said: When we have several scripts in a page, the global variables & functions will get overwritten if their name repeats. One solution is to make the variables as properties & functions as methods of an object, and access them via the object name. But will this prevent the issue of variables getting into the global namespace? <script> var movie = { name: "a", trailer: function(){ //code } }; </script> In the above code which elements gets added to the global namespace? a) Just the object name - movie b) Object name as well as the properties and methods inside it – movie, movie.name, movie.trailer()

    Read the article

  • slowly rotate an object towards another object

    - by numerical25
    I have an object that points in the direction of another object (i.e. it rotates to the direction that the second objects x and y coordinates are at) below is the code I use. var distx = target.x - x; var disty = target.y - y; var angle:Number = Math.atan2(disty, distx); var vx:Number = Math.cos(angle) * cspeed; var vy:Number = Math.sin(angle) * cspeed; rotation = angle * 180/Math.PI; x += vx; y += vy; as you can see. Not only does it rotate towards the target object, but it also moves towards it too. When I play the movie, the object instantly points to the targeted object and moves towards it. I would like for it to slowly turn towards the object instead of instantly turning towards it. anyone know how to do this.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >