w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Casting specific observablecollection to a generic observablecollection
You can't use ObservableCollection<T> as if it were both covariant and contravariant in T. That's pretty meaningless. Maybe you want to copy the collections (but that may be expensive!): public abstract HeadOffice<T> : IOffice where T : Employee { ObservableCollection<T> _employees = new ObservableCollection<T>(); public ObservableCollection<Employee> Employees { get { return new ObservableCollection<Employee>(_employees); } set { _employees.Clear(); foreach (var e in value) { var t = e as T; if (t == null) throw new InvalidOperationException("..."); _empl

Categories : C#

Replace Entire ObservableCollection with another ObservableCollection
You have some options: Implement INotifyPropertyChanged so you can inform the UI that the value of Items has changed. This does not utilize the fact that INotifyCollectionChanged is implemented on ObservableCollection. It will work, but it defeats the purpose of using an ObservableCollection in the first place. This is not recommended but it works. Related Reading Example Use the ObservableCollection's Add/Remove/Modify/Update methods to modify it in conjunction with the Dispatcher. Note: without the Dispatcher, you will get a NotSupportedException because CollectionViews do not support changes to their SourceCollection from a thread different from the Dispatcher thread. Use the ObservableCollection's Add/Remove/Modify/Update methods to modify it in conjunction with BindingOperati

Categories : C#

Can i use LINQ to populate an ObservableCollection of ObservableCollection
I'm not completely sure where child4 is coming from but based on your above structure this will get you Child3. var child3 = observableOfClassA .SelectMany(a => a.classBItems) // flattens list to all classBItems .SelectMany(b => b.classBSubItems) // flattens list to classBItems.classBSubItems .Where(bSub => bSub.name == "child3s Name goes here") // replace with your where clause .FirstOrDefault();

Categories : C#

Binding ListBoxItem properties when ListBox is bound to ObservableCollection
The DataTemplate specifies the template (UI presentation) of the content of the list box item. What you need to style is the item container itself which can be done via the ItemContainerStyle property of the ListBox.

Categories : C#

INPCs not firing for multiple properties from setter of "driving" ObservableCollection
I think in general your approach is going to give you issues. Instead of implementing the logic in the getters of your properties, you should consider making your properties much "dumber". I would move this logic out of the properties into a helper method that modifies your available options: private readonly ObservableCollection<AttributeValuesLibrary> _availableShapesCollection = new ObservableCollection<AttributeValuesLibrary>(); private readonly ObservableCollection<AttributeValuesLibrary> _availableColorsCollection = new ObservableCollection<AttributeValuesLibrary>(); public ObservableCollection<AttributeValuesLibrary> AvailableShapesCollection { get { return _availableShapesCollection; } } public ObservableCollection<AttributeValuesLibr

Categories : C#

ObservableCollection don't modify view
Once you are changing record after that your property is not Notifying.so please Notify after changing the collection. Add below line in RefreshGridSource method after collection changed . RaisePropertyChanged("GridItems");

Categories : Wpf

How to Bind an Image from an ObservableCollection to View
Your binding needs to point to the correct property in the Picture class which is Source in your case. Try this Xaml <Image x:Name="photo" Grid.Row="0" Source="{Binding Source}" Margin="12" HorizontalAlignment="Center" VerticalAlignment="Center" toolkit:TiltEffect.IsTiltEnabled="True"/>

Categories : C#

ObservableCollection Bound from ViewModel Does Not Update View
The problem is that you are assigning an IOrderedEnumerable to Recent.ItemSource and not a ObservableCollection. In LoadAllPicturesFromIsolatedStorage() create a temporary List where you add the loaded data from your file and then create the ObservableCollection. PictureRepository.cs #region Constants public const string IsolatedStoragePath = "Pictures"; #endregion #region Properties public ObservableCollection<Picture> Pictures { get; private set; } #endregion #region Singleton Pattern private PictureRepository() { LoadAllPicturesFromIsolatedStorage(); } public static readonly PictureRepository Instance = new PictureRepository(); #endregion /// <summary> /// Saves to local storage /// This method gets two parameters: the captured picture instance a

Categories : C#

How to Change Size of Images in View when Populated by ObservableCollection
You can set your ItemTemplate like @tanuj_loop suggests but I would suggest potentially also embedding the item in a ViewBox and applying your size changes to it instead of directly to the image to ensure you retain the resolution of the image but get the size constraints you're after, so something like; <ListBox.ItemTemplate> <DataTemplate> <ViewBox MaxHeight="128" MaxWidth="128"> <Image Source="{Binding }"/> </ViewBox> </DataTemplate> </ListBox.ItemTemplate> This way your ViewBox handles all your potential resizing issues for you, and your images still come out as crisp as you wanted. Hope this helps.

Categories : Image

C++ Unordered Map Exposed From DLL char
You shouldn't use char* as the key, otherwise, you will replay on the pointer address as you key rather than the content of the string. You may need to change you container std::unordered_map to a normal array [].

Categories : C++

What are consequences of having GCM SENDER ID being exposed?
They will not be able to use your GCM Sender ID to publish notifications. Remember that when you obtained the Sender ID, you have to also submit your application's package name and your release signing key's SHA-1 signature. That signature is bound to the GCM Sender ID so that only applications signed by your release key are able to register and receive GCM notifications. Google Play will also not allow apps with duplicate package name to be published, so nobody can create a fake app with your package name that is already in the Play store. However, nothing is 100% secured. I presume a hacker could also figure out your SHA-1 signing key and hack the APK in such a way to fool the system to think the app is signed by your release key. I have seen apps are 'cracked' this way to circumvent

Categories : Java

How 'exposed' do you store a password in a session?
Why would you need to store the user's password in the session at all? I can't see any particular need for it, and it's just creating a potential security risk for no reason at all. Instead, just store the username and, possibly, a flag stating that the user has been authenticated. Of course, you should clear the flag (and/or just wipe the entire session data) when the user logs out, so that an attacker who somehow gets access to old session cookies can't resume the session after logout. You may also want to store a "last access" timestamp in the session, so that you can let old stale sessions time out. Or you could rely on your session framework's built-in session expiration behavior, but it may still be a good idea to have a backup mechanism fully under your app's direct control. P

Categories : Security

Securing the API exposed in chrome extension
No, you can not ensure that only your Chrome extension is making the requests. Once your code leaves your control (i.e. the client has it), there is no guarantee that it isn't tampered with or reverse engineered. What you can do though, is make the user log in before accessing your API. By authenticating, you aren't verifying that the user is using your Chrome extension, but you do have someone to blacklist if your server becomes the subject of large traffic. You can have the user of the chrome extension create an account one time and then the extension can send those credentials to your server with each request. You may be tempted to try things like embedding a secret token or passphrase, but this will only stop the lazy attackers. Furthermore it may give you a false sense of secu

Categories : Api

What kind of data exposed from linkedin API
Whatever level of information the user has specified for show. But in most cases, it will be name, location, job title, company, past companies, education. You can also drill in to information such as your contacts. I would checkout https://developer.linkedin.com/

Categories : Api

How to specify custom SoapAction without service interface exposed
Set the ReplyAction: [OperationContract(ReplyAction="http://Microsoft.WCF.Documentation/ResponseToOCAMethod")] string SampleMethod(string msg);

Categories : C#

Exposed views filter made of titles
If I were trying to accomplish this I would add a taxonomy vocabulary for these images, then I would add a field to the image content type referencing this vocabulary. After that, I would use create a Rule that would react to saving a new image and add a new taxonomy term to that image that is the title entered. You can then easily create a filter in views to filter off that taxonomy term and expose that as a dropdown. By doing this each image should have a taxonomy term attached to it that is the image's title. As images are added the taxonomy terms should appear in the dropdown. Let me know if you need any additional guidance.

Categories : Drupal

Modify the ports for the exposed API in WSO2 API manager
You just have to change the Port offset of the API Manager Server. For that change offset configuration in <PRODUCT_HOME>/repository/conf/carbon.xml <Offset>1</Offset> This will change the NIO port which is 8280 by default to 8281 (8280 + 1). After that make sure to edit all the hardcoded endpoints of default APIs available by following[1] [1]http://docs.wso2.org/wiki/display/AM140/Configuring+Port+Offset

Categories : Wso2

Change Exposed elements (jQuery Tools )
Probably not a good idea to put a click event inside a click event. I'm not familiar with this mask plugin, but speaking in the abstract, you can clean it up by doing something like this: $('.open').click(function() { $('#workspace_menu').show(); }); $('.tutorial, .next').click(function() { $('.mask').hide(); $('.action_list').show(); }); Make sure you separate multiple selectors with a comma in the case of .tutorial and .next

Categories : Javascript

Spring MVC & Freemarker session attribute not exposed
You have a session problem because of that redirectAttributes.addFlashAttribute(). which means addFlashAttribute actually stores the attributes in a flashmap (which is internally maintained in the users session and removed once the next redirected request gets fulfilled), Just try without redirectAttributes.addFlashAttribute() you will get session. May be this will help you

Categories : Java

Drupal Views Exposed Filters with approximate matches
You could create 2 different views. One being the page you already created with the exposed filter, and the other being a block with almost the exact same settings, but make the filter less strict (ex. "contains" vs. "is equal to"). Then you could print the block below your results on the page, possibly in the footer, and call it something along the lines of "Approximate Matches". If you're not sure how to print a block, there's a good description here. There may be a more efficient way of doing this, but this is the first thing that came to mind.

Categories : Drupal

How are events declared in an interface exposed in a WCF client proxy?
C# event is a C# construct. It is bound to C# language. WCF does not expose such constructs over its endpoints. If IInterface is your service contract and has a C# event. This event will not be visible/created on the IInterface generated at client proxy. WCF uses Callback contracts to implement events.

Categories : C#

Getting username and password exposed in POST parameters when created a new user
Change your create method to: /** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new User; if (isset($_POST['User'])) { $model->attributes = $_POST['User']; $model->password = crypt($model->password, 'mysalt123'); if ($model->save()) $this->redirect(array('view', 'id' => $model->primaryKey)); } // Reset password field $model->password = ""; $this->render('create', array( 'model' => $model, )); } Change that elseif from this: elseif ($users->password !== crypt($this->password, $users->password)) To this: elseif (strcmp(crypt($this->password, 'mysalt123'), $users->

Categories : PHP

How can I add a comment (for developers, ie not exposed on output HTML) to an Angular template?
Angular doesn't have template comment support built in. You could, however, create a comment directive to support it, like this. app.directive('templateComment', function () { return { restrict: 'E', compile: function (tElement, attrs) { tElement.remove(); } }; }); Markup would then be: <template-comment>Put your comment here.</template-comment> Alternately, you could use standard html comments, and then strip them out of your production code before deployment. Consider this grunt task, if you'd like to support block comments - https://github.com/philipwalton/grunt-strip-code Specify a start comment and an end comment, and your comment block will be stripped out of the production code, assuming your add this task to your depl

Categories : Angularjs

Retrieving a static pointer from a closed-source library, not exposed by the public interface
From my understanding, classes operate similarly to structs in C in terms of how they're set up. So, perhaps by doing ptrToClassObject+offset it might just work. There's a way to get the offset of the class members, I just don't know anything about how that's set up.

Categories : C++

Issue with calling publicly exposed method from event handler in jQuery plugin
UPDATE: remove this from the function and it will work. The one before: changeBackgroundColor = function() { $('#square').css('background','red'); }; UPDATE 2: If you want it public, do window.changeBackgroundColor()

Categories : Jquery

Drupal 7 - Rendering Exposed Form Elements as Icons via Custom Module, outputting string instead of html
I decided to pull this off using jQuery, as achieving the desired affect using a custom module was not pragmatic and may have, in fact, been overkill. Following is the poorly refactored but working code which got me there: (function($) { $(document).ready(function(){ var link = '<a href="http://project.local/blog-posts?field_blog_post_type_tid=', id = '#edit-field-blog-post-type-tid-'; $(id + 'all').html(link + 'All"><span class="icon-container"><i class="icon-undo"></i></span></a>'); $(id + '3').html(link + '3"><span class="icon-container"><i class="icon-music"></i></span></a>'); $(id + '2').html(link + '2"><span class="icon-container"><i class="icon-camera"></i></sp

Categories : Drupal

ObservableCollection not updating the UI
If the properties are being changed on your Station objects, you need to implement INotifyPropertyChanged on it, and fire the PropertyChanged event in your property setters. It seems like the chart object isn't being notified when your other thread changes the properties. The ObservableCollection will only cause an update in the chart when Station objects are added or removed, not when their properties change. You say that when you hover over the chart you see the updated values, but this may be because the chart is actually calling the getter on the property to display that, so you will see the updated value there (but I'm speculating on this).

Categories : C#

ObservableCollection and DisplayMemberBinding
Since you bind ItemsSource to ObservableCollection<Point> it means that each item is of a Point type which has ValueX and ValueY declared as fields which are not valid binding source. Change them to properties: public double ValueX { get; private set; } public double ValueY { get; private set; } Besides you use Mode=TwoWay for something that is read only. This should be changed to OneWay. If you want to leave TwoWay binding then remove private from the setter but then also you'll need to change GridViewColumn.CellTemplate to be some TextBox instead of using DisplayMemberBinding which is for display only.

Categories : Wpf

How to mock ObservableCollection
I don't think you should mock such base types as List, ObservableCollection, or DateTime (even if it was possible). They are reliable and unlikely to change. Simply use ObservableCollection in your test instead of trying to re-implement it's count-increasing functionality. You always can do state-based verification: var items = new ObservableCollection<int>(); // Do stuff Assert.That(items.Count, Is.EqualTo(5)); If you are using your custom type Foo which is inherited from ObservableCollection<Int32> then you can also implement some IFoo interface which will be easy to mock: public class Foo : ObservableCollection<Int32>, IFoo

Categories : C#

Is there a way to sort an Observablecollection?
'OrderregelsGegroepeerd = New ObservableCollection(Of clsOrderItems)(l) Dim NewIndex As Integer = 0 For Each regel As clsOrderItems In l Dim idx As Integer = OrderregelsGegroepeerd.IndexOf(regel) OrderregelsGegroepeerd.Move(idx, NewIndex) NewIndex = NewIndex + 1 Next So that's the way i come up with, now i just have a small problem with the converter behind the new item but thats not a big deal! Thanks for the reply from keyboardP, that i actually only saw it before i figured the problem, but is still a good source of infomation.

Categories : Vb.Net

How to serialize ObservableCollection in C#?
ObservableCollection<T> implements IEnumerable<T> so you should be able to convert it to a List<T> or T[] simply enough with the ToList()/ToArray() extensions. Both of which can be serialized with the DataContractSerializer without issue (as long as the attributes a properly applied).

Categories : C#

Get single record from observablecollection
listbox.datasource = list.select( x => x ).where( x.id == id); Hope it helps. I suggest maybe using a CollectionView that you bind to the listbox, and filter the list using the code above, and the listbox updates itself.

Categories : C#

How to cast a List to an ObservableCollection in wpf?
you can do it by using extension method public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> coll) { var c = new ObservableCollection<T>(); foreach (var e in coll) c.Add(e); return c; } or you can use this constructor The elements are copied onto the ObservableCollection in the same order they are read by the enumerator of the list. ObservableCollection<YourObject> collection = new ObservableCollection<YourObject>(yourList);

Categories : C#

How can I do CanDelete validation on ObservableCollection?
You shouldn't delete row directly in the Grid, UI is not responsible for performing Business Actions, this should be performed by ViewModel and before that ViewModel should do validation. AllowDelete="False" in DataGrid: <DataGrid.InputBindings> <KeyBinding Key="Delete" Command="{Binding DeleteOrderCommand}" /> </DataGrid.InputBindings> On View Model you will have DeleteOrderCommand. If you replace this View with some other technology and new Control does not have delete row option you would use button. So you could still reuse your ViewModel as button would bind to the DeleteOrderCommand or to the method that this command is calling, as well your validation is in ViewModel so it hasn't disappeared when you switched to View in new technology. UPDATE: You can u

Categories : C#

mvvm observablecollection and binding
In the Xaml file of your user control named TableControl, add DataContext={Binding} in the root element and I think it should then work (if it's not present). It could also be not working if you have DataContext set inside the code behind of your user control's (e.g.TableControl.xaml.cs) file to something like this.DataContext = this; which makes user control not use the DataContext of Tables collection. You can use this SO Answer to check what exactly is in the DataContext of your user control TableControl. Edit: Try below also, because as per your comment, DataContext for TableControl is conflicting: <DataTemplate> <controls:TableControl DataContext="{Binding}" TableNumber="{Binding Id}" North="{Binding North}" East="{Binding Eas

Categories : C#

Populating a ListBox (WPF) with an ObservableCollection
You need to remove the DisplayMemberPath specifier. This is saying to look for the List1 property on each item of List1. Since List1 merely contains a set of strings, there is no List1 property on System.String, so you get a binding error.

Categories : C#

How to check for the duplicates in an ObservableCollection?
Create a new AddressComparer class implementing IEqualityComparer interface Now you use Contains method if(Addresses.Contains(Address,new AddressComparer())) { //your code }

Categories : C#

how to bind a wpf table to an observablecollection?
The FlowDocument control does not support DataBinding as explained here While there are many great features in flow documents, if your documents are generated from dynamic data, you have a bit of a problem: there is no support for data binding in flow documents. The flow document elements (Section, Table, Run, Paragraph and the like) are dependency objects, but don't define any dependency properties that would allow you to dynamically change or generate content. There is a work around given at the above link, which might be helpful for you.

Categories : C#

Combine List and ObservableCollection
The simple answer to your question is 'yes, but with some work'. The ObservableCollection<T> class extends the Collection<T> class, which implements the IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable interfaces - the same as the List<T> class. However, the ObservableCollection<T> class also implements the INotifyCollectionChanged and INotifyPropertyChanged interfaces, so these are the main difference between the two. Therefore you could extend the List<T> class and manually implement the INotifyCollectionChanged and INotifyPropertyChanged interfaces yourself to get the best of both worlds. Having said that, after manually adding AddRange and Sort methods to my custom ObservableCollection<T> base class, I ha

Categories : C#

How to convert Querytable to ObservableCollection
You are not initizalizing the PersonList, so PersonList is null. That's why you are getting NullReferenceException, Object reference not set to an instance of an object. public async Task<bool> GetPersons() { try { var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.db3"); //Initialize the PersonList, so PersonList won't be null. PersonList = new PersonCollection(); using (var db = new SQLite.SQLiteConnection(dbPath)) { var listadepersonas = from x in db.Table<Person>() select x; foreach (var persona in listadepersonas) { PersonList.Add(new Person() { id = persona.id, Name = persona.Last

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.