Search Results

Search found 369 results on 15 pages for 'observablecollection'.

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

  • Trouble using CollectionViewSource in Silverlight

    - by Johnny
    Hi, I having some trouble when implementing the CollectionViewSource in silverlight. I'm new in this topic, so basically I've been following what I find searching through the web. Here's what I've been trying to do so far. I'm creating a CollectionViewSource in the resources tag: <UserControl.Resources> <CollectionViewSource x:Key="TestCVS"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="Value" Direction="Ascending" /> </CollectionViewSource.SortDescriptions> </CollectionViewSource> </UserControl.Resources> Then I'm binding my TestCVS in a HierarchicalDataTemplate: <common:HierarchicalDataTemplate ItemsSource="{Binding Source={StaticResource TestCVS}}"> <common:HierarchicalDataTemplate.ItemTemplate> <common:HierarchicalDataTemplate> <Border BorderBrush="#FF464646" BorderThickness="1" CornerRadius="3" Padding="5"> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <TextBlock TextWrapping="Wrap" Text="{Binding MyClassField}"/> </StackPanel> </Grid> </Border> </common:HierarchicalDataTemplate> </common:HierarchicalDataTemplate.ItemTemplate> </common:HierarchicalDataTemplate> Now, in the code behind I'm assigning the Source for the TestCVS in a property, like this: private ObservableCollection<MyClass> _MyClass; public ObservableCollection<MyClass> MyClass { get { return _MyClass; } set { var testCVS = (this.Resources["TestCVS"] as CollectionViewSource); if (testCVS != null) testCVS.Source = value; } } After testing this I realize that the information is not showing on screen and I don't really know why, can anyone help me on this matter? Hope this makes any sense, thanks in advance!

    Read the article

  • WPF/MVVM: Delegating a domain Model collection to a ViewModel

    - by msfanboy
    A domain model collection (normally a List or IEnumerable) is delegated to a ViewModel. Thats means my CustomerViewModel has a order collection of type List or IEnumerable. No change in the list is recognized by the bound control. But with ObservableCollection it is. This is a problem in the MVVM design pattern. How do you cope with it?

    Read the article

  • Binding to a collection of DependencyObjects in Silverlight 4

    - by Meik
    As of Silverlight 4 it is possible to data bind against a DependencyObject (instead of a Framework element in previous versions). So far so good, but how do I bind agains a collection of DependencyObjects. The DataContext is not passed from the ObservableCollection to the collection elements, so that the DependencyProperties of the DependencyObjects are never called (neither the changed events). Neither the DependencyObject offers SetBinding or DataContext to initialize the binding manually. Thanks for any advice here.

    Read the article

  • bind linq expression

    - by Neir0
    Hi, I have a ListView and ObservableCollection in my wpf application. I want to bind linq expression to ListView: lv_Results.DataContext = store.Where(x => x.PR > 5); But when i add new elements to store collection, lv_Results doesnt updates. How can i update ListView?

    Read the article

  • Silverlight with MVVM Inheritance: ModelView and View matching the Model

    - by moonground.de
    Hello Stackoverflowers! :) Today I have a special question on Silverlight (4 RC) MVVM and inheritance concepts and looking for a best practice solution... I think that i understand the basic idea and concepts behind MVVM. My Model doesn't know anything about the ViewModel as the ViewModel itself doesn't know about the View. The ViewModel knows the Model and the Views know the ViewModels. Imagine the following basic (example) scenario (I'm trying to keep anything short and simple): My Model contains a ProductBase class with a few basic properties, a SimpleProduct : ProductBase adding a few more Properties and ExtendedProduct : ProductBase adding another properties. According to this Model I have several ViewModels, most essential SimpleProductViewModel : ViewModelBase and ExtendedProductViewModel : ViewModelBase. Last but not least, according Views SimpleProductView and ExtendedProductView. In future, I might add many product types (and matching Views + VMs). 1. How do i know which ViewModel to create when receiving a Model collection? After calling my data provider method, it will finally end up having a List<ProductBase>. It containts, for example, one SimpleProduct and two ExtendedProducts. How can I transform the results to an ObservableCollection<ViewModelBase> having the proper ViewModel types (one SimpleProductViewModel and two ExtendedProductViewModels) in it? I might check for Model type and construct the ViewModel accordingly, i.e. foreach(ProductBase currentProductBase in resultList) if (currentProductBase is SimpleProduct) viewModels.Add( new SimpleProductViewModel((SimpleProduct)currentProductBase)); else if (currentProductBase is ExtendedProduct) viewModels.Add( new ExtendedProductViewModels((ExtendedProduct)currentProductBase)); ... } ...but I consider this very bad practice as this code doesn't follow the object oriented design. The other way round, providing abstract Factory methods would reduce the code to: foreach(ProductBase currentProductBase in resultList) viewModels.Add(currentProductBase.CreateViewModel()) and would be perfectly extensible but since the Model doesn't know the ViewModels, that's not possible. I might bring interfaces into game here, but I haven't seen such approach proven yet. 2. How do i know which View to display when selecting a ViewModel? This is pretty the same problem, but on a higher level. Ended up finally having the desired ObservableCollection<ViewModelBase> collection would require the main view to choose a matching View for the ViewModel. In WPF, there is a DataTemplate concept which can supply a View upon a defined DataType. Unfortunately, this doesn't work in Silverlight and the only replacement I've found was the ResourceSelector of the SLExtensions toolkit which is buggy and not satisfying. Beside that, all problems from Question 1 apply as well. Do you have some hints or even a solution for the problems I describe, which you hopefully can understand from my explanation? Thank you in advance! Thomas

    Read the article

  • How can I speed up the rendering of my WPF ListBox?

    - by Justin Bozonier
    I have a WPF ListBox control (view code) and I am keeping maybe like 100-200 items in it. Every time the ObservableCollection it is bound to changes though it takes it a split second to update and it freezes the whole UI. Is there a way to add elements incrementally or something I can do to improve the performance of this control?

    Read the article

  • How can I modify my classes to use it's collections in WPF TreeView

    - by Victor
    Hello, i'am trying to modify my objects to make hierarchical collection model. I need help. My objects are Good and GoodCategory: public class Good { int _ID; int _GoodCategory; string _GoodtName; public int ID { get { return _ID; } } public int GoodCategory { get { return _GoodCategory; } set { _GoodCategory = value; } } public string GoodName { get { return _GoodName; } set { _GoodName = value; } } public Good(IDataRecord record) { _ID = (int)record["ID"]; _GoodtCategory = (int)record["GoodCategory"]; } } public class GoodCategory { int _ID; string _CategoryName; public int ID { get { return _ID; } } public string CategoryName { get { return _CategoryName; } set { _CategoryName = value; } } public GoodCategory(IDataRecord record) { _ID = (int)record["ID"]; _CategoryName = (string)record["CategoryName"]; } } And I have two Collections of these objects: public class GoodsList : ObservableCollection<Good> { public GoodsList() { string goodQuery = @"SELECT `ID`, `ProductCategory`, `ProductName`, `ProductFullName` FROM `products`;"; using (MySqlConnection conn = ConnectToDatabase.OpenDatabase()) { if (conn != null) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = productQuery; MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Add(new Good(rdr)); } } } } } public class GoodCategoryList : ObservableCollection<GoodCategory> { public GoodCategoryList () { string goodQuery = @"SELECT `ID`, `CategoryName` FROM `product_categoryes`;"; using (MySqlConnection conn = ConnectToDatabase.OpenDatabase()) { if (conn != null) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = productQuery; MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Add(new GoodCategory(rdr)); } } } } } So I have two collections which takes data from the database. But I want to use thats collections in the WPF TreeView with HierarchicalDataTemplate. I saw many post's with examples of Hierarlichal Objects, but I steel don't know how to make my objects hierarchicaly. Please help.

    Read the article

  • Combobox INotifyPropertyChanged event not raised!!!

    - by nagiah
    I created a combobox and set observable collection as the itemsource and implemented INotifyPropertyChanged on the observable collection item. Even after that, when I select different item in the combobox, the OnPropertyChange method is not invoked. I think I am not making the binding properly. Could any one please correct me/ suggest me in this regard. ---------------------------------MainPage.xaml--------------------------------------------------- <StackPanel Width="300"> <ComboBox Name="cboName"></ComboBox> <TextBox Name="tbxName" Text="{Binding Path=name,Mode=TwoWay,ElementName=cboName}" ></TextBox> </StackPanel> ---------------------------MainPage.xaml.cs----------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; namespace MasterDetailsUpdate { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); Loaded += new RoutedEventHandler(MainPage_Loaded); } void MainPage_Loaded(object sender, RoutedEventArgs e) { ObservableCollection<Person> persons = new ObservableCollection<Person>(); persons.Add(new Person { city = "c1", name = "n1" }); persons.Add(new Person { city = "c2", name = "n2" }); persons.Add(new Person { city = "c3", name = "" }); persons.Add(new Person { city = "c4", name = "" }); persons.Add(new Person { city = "c5", name = "n1" }); cboName.ItemsSource = persons; cboName.DisplayMemberPath = "name"; } } public class Person : INotifyPropertyChanged { private string _name; private string _city; public string name { set { _name = value; OnPropertyChanged("name"); } get { return _name; } } public string city { set { _city = value; OnPropertyChanged("city"); } get { return _city; } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } } Thank You

    Read the article

  • Silverlight3 bind checkbox list to a datagrid

    - by Stester
    I have a enum, like public enum TestType { Red = 1, Blue = 2, Green = 3, Black = 4 } I want to attach those values to a datagrid as checkboxes in silverlight 3. (I would like to bind to a listview, but its not exists in silverlight) Manage to get the enums to a ObservableCollection, any help to bind to datagrid? I tried with ItemsSource="{Binding Path=nameOfTheObservableCollection, }"

    Read the article

  • WPF ComboBox drop-down (data bound) values not changing

    - by Jefim
    I bind the ItemsSource of a ComboBox to an ObservableCollection<MyClass>. In code I change the collection (e.g. edit the MyClass.Name property). The problem: the change is not reflected in the dropdown box if the ComboBox, yet when I seled the item from the dropdown it is displayed correctly in the selected item box of the ComboBox. What's going on? :) PS MyClass has INotifyPropertyChanged implemented

    Read the article

  • Issue with binding Collection type of dependency property in style

    - by user344101
    Hi, I have a customcontrol exposing a Dependency property of type ObservableCollection. When i bind this properrty directly as part ofthe control's mark up in hte containing control everythihng works fine /< temp:EnhancedTextBox CollectionProperty="{Binding Path=MyCollection, Mode=TwoWay}"/ But when i try to do the binding in the style created for the control it fails, /< Style x:Key="abc2" TargetType="{x:Type temp:EnhancedTextBox}" <Setter Property="CollectionProperty" Value="{Binding Path=MyCollection, Mode=TwoWay}"/> Please help !!!!! Thanks

    Read the article

  • Converting ObsevableCollection foreach to lambda.

    - by Jitendra Jadav
    Hello Guys, I am working some ObservableCollection converting to lembda it will give me error this is my actual code . foreach (var item in Query) { userDetail.Add(new UserDatail(item.ID,item.Name, item.Address, item.City, item.Pin, item.Phone)); } and I am try to add as lembda Query.ToList().ForEach(x => userDetail.Add(x.ID,x.Name,x.Address,x.City,x.Pin,x.Phone)); This will give me error. Thanks..

    Read the article

  • Is it ok to reference .Net assemblies liberally?

    - by panamack
    I'm building a WPF application and working with the MVVM pattern. I have 4 projects in my solution, 3 class libraries, Data, Model and ViewModel and the WPF executable View. Is there anything wrong with the Model referencing WindowsBase so that I can use ObservableCollection<T> for example or can I just make use of what I intuitively feel I need without worrying about the original purposes of the class in the framework e.g. collection databinding.

    Read the article

  • Modifying an observable collection bound to a ListBox

    - by Rohit Kandhal
    I've a collection in viewmodel binded to listbox. I want to hide a particular type from the collection. Here is the code: public ObservableCollection [YZModeModelView] YZModeModelView { return this.XModelVIew.YZModelViewCollection; } I want to a particular type of model view's from YZModelViewCollection. eg. ModelView's with property abc set to null. Any suggestions ...

    Read the article

  • WP7 databinding displays int but not string?

    - by user1794106
    Whenever I test my app.. it binds the data from Note class and displays it if it isn't a string. But for the string variables it wont bind. What am I doing wrong? Inside my main: <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <ListBox x:Name="Listbox" SelectionChanged="listbox_SelectionChanged" ItemsSource="{Binding}"> <ListBox.ItemTemplate> <DataTemplate> <Border Width="800" MinHeight="60"> <StackPanel> <TextBlock x:Name="Title" VerticalAlignment="Center" FontSize="{Binding TextSize}" Text="{Binding Name}"/> <TextBlock x:Name="Date" VerticalAlignment="Center" FontSize="{Binding TextSize}" Text="{Binding Modified}"/> </StackPanel> </Border> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> </Grid> in code behind: protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { MessageBox.Show("enters onNav Main"); DataContext = null; DataContext = Settings.NotesList; Settings.CurrentNoteIndex = -1; Listbox.SelectedIndex = -1; if (Settings.NotesList != null) { if (Settings.NotesList.Count == 0) { Notes.Text = "No Notes"; } else { Notes.Text = ""; } } } and public static class Settings { public static ObservableCollection<Note> NotesList; static IsolatedStorageSettings settings; private static int currentNoteIndex; static Settings() { NotesList = new ObservableCollection<Note>(); settings = IsolatedStorageSettings.ApplicationSettings; MessageBox.Show("enters constructor settings"); } notes class: public class Note { public DateTimeOffset Modified { get; set; } public string Title { get; set; } public string Content { get; set; } public int TextSize { get; set; } public Note() { MessageBox.Show("enters Note Constructor"); Modified = DateTimeOffset.Now; Title = "test"; Content = "test"; TextSize = 32; } }

    Read the article

  • Binding a collection to Listbox

    - by Blub
    Hi, I basically started today with WPF, and I'm astounded by how difficult it is to do binding. I have an array of Textboxes, in an ObservableCollection, and just want to bind that in my Listbox, so that they arrange themselves vertically. I have fiddled around with this for 3 already, can you help? I'm working in a Wpf "UserControl", not a window as so many tutorials seem to rely on.

    Read the article

  • WP7 Return the last 7 days of data from an xml web service

    - by cvandal
    Hello, I'm trying to return the last 7 days of data from an xml web service but with no luck. Could someone please explain me to how I would accomplish this? The XML is as follows: <node> <api> <usagelist> <usage day="2011-01-01"> <traffic name="total" unit="bytes">23579797</traffic> </usage> <usage day="2011-01-02"> <traffic name="total" unit="bytes">23579797</traffic> </usage> <usage day="2011-01-03"> <traffic name="total" unit="bytes">23579797</traffic> </usage> <usage day="2011-01-04"> <traffic name="total" unit="bytes">23579797</traffic> </usage> </usagelist> </api> </node> EDIT The data I want to retrieve will be used to populate a line graph. Specificly I require the day attribute value and the traffic element value for the past 7 days. At the moment, I have the code below in place, howevewr it's only showing the first day 7 times and traffic for the first day 7 times. XDocument xDocument = XDocument.Parse(e.Result); var values = from query in xDocument.Descendants("usagelist") select new History { day = query.Element("usage").Attribute("day").Value, traffic = query.Element("usage").Element("traffic").Value }; foreach (History history in values) { ObservableCollection<LineGraphItem> Data = new ObservableCollection<LineGraphItem>() { new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) }, new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) }, new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) }, new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) }, new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) }, new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) }, new LineGraphItem() { yyyymmdd = history.day, value = double.Parse(history.traffic) }, }; lineGraph1.DataSource = Data; }

    Read the article

  • unprotected access to member in property get

    - by Lenik
    I have a property public ObservableCollection<string> Name { get { return _nameCache; } } _nameCache is updated by multiple threads in other class methods. The updates are guarded by a lock. The question is: should I use the same lock around my return statement? Will not using a lock lead to a race condition?

    Read the article

  • WCF Data Service BeginSaveChanges not saving changes in Silverlight app

    - by Enigmativity
    I'm having a hell of a time getting WCF Data Services to work within Silverlight. I'm using the VS2010 RC. I've struggled with the cross domain issue requiring the use of clientaccesspolicy.xml & crossdomain.xml files in the web server root folder, but I just couldn't get this to work. I've resorted to putting both the Silverlight Web App & the WCF Data Service in the same project to get past this issue, but any advice here would be good. But now that I can actually see my data coming from the database and being displayed in a data grid within Silverlight I thought my troubles were over - but no. I can edit the data and the in-memory entity is changing, but when I call BeginSaveChanges (with the appropriate async EndSaveChangescall) I get no errors, but no data updates in the database. Here's my WCF Data Services code: public class MyDataService : DataService<MyEntities> { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } protected override void OnStartProcessingRequest(ProcessRequestArgs args) { base.OnStartProcessingRequest(args); HttpContext context = HttpContext.Current; HttpCachePolicy c = HttpContext.Current.Response.Cache; c.SetCacheability(HttpCacheability.ServerAndPrivate); c.SetExpires(HttpContext.Current.Timestamp.AddSeconds(60)); c.VaryByHeaders["Accept"] = true; c.VaryByHeaders["Accept-Charset"] = true; c.VaryByHeaders["Accept-Encoding"] = true; c.VaryByParams["*"] = true; } } I've pinched the OnStartProcessingRequest code from Scott Hanselman's article Creating an OData API for StackOverflow including XML and JSON in 30 minutes. Here's my code from my Silverlight app: private MyEntities _wcfDataServicesEntities; private CollectionViewSource _customersViewSource; private ObservableCollection<Customer> _customers; private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) { _wcfDataServicesEntities = new MyEntities(new Uri("http://localhost:7156/MyDataService.svc/")); _customersViewSource = this.Resources["customersViewSource"] as CollectionViewSource; DataServiceQuery<Customer> query = _wcfDataServicesEntities.Customer; query.BeginExecute(result => { _customers = new ObservableCollection<Customer>(); Array.ForEach(query.EndExecute(result).ToArray(), _customers.Add); Dispatcher.BeginInvoke(() => { _customersViewSource.Source = _customers; }); }, null); } } private void button1_Click(object sender, RoutedEventArgs e) { _wcfDataServicesEntities.BeginSaveChanges(r => { var response = _wcfDataServicesEntities.EndSaveChanges(r); string[] results = new[] { response.BatchStatusCode.ToString(), response.IsBatchResponse.ToString() }; _customers[0].FinAssistCompanyName = String.Join("|", results); }, null); } The response string I get back data binds to my grid OK and shows "-1|False". My intent is to get a proof-of-concept working here and then do the appropriate separation of concerns to turn this into a simple line-of-business app. I've spent hours and hours on this. I'm being driven insane. Any ideas how to get this working?

    Read the article

  • Binding a property to change the listbox items foreground individually for each item

    - by Eyal-Shilony
    I'm trying to change the foreground color of the items in the ListBox individually for each item, I've already posted a similar question but this one is more concrete. I hoped that the state of the color is reserved for each item added to the ListBox, so I tried to create a property (in this case "HotkeysForeground"), bind it and change the color when the items are added in the "HotkeyManager_NewHotkey" event, the problem it's changing the foreground color for all the items in the ListBox. How can I do that per item ? Here is the ViewModel I use. namespace Monkey.Core.ViewModel { using System; using System.Collections.ObjectModel; using System.Windows.Media; using Monkey.Core.SystemMonitor.Accessibility; using Monkey.Core.SystemMonitor.Input; public class MainWindowViewModel : WorkspaceViewModel { private readonly FocusManager _focusManager; private readonly HotkeyManager _hotkeyManager; private readonly ObservableCollection<string> _hotkeys; private Color _foregroundColor; private string _title; public MainWindowViewModel() { _hotkeys = new ObservableCollection<string>(); _hotkeyManager = new HotkeyManager(); _hotkeyManager.NewHotkey += HotkeyManager_NewHotkey; _focusManager = new FocusManager(); _focusManager.Focus += FocusManager_Focus; } public Color HotkeysForeground { get { return _foregroundColor; } set { _foregroundColor = value; OnPropertyChanged(() => HotkeysForeground); } } public ReadOnlyObservableCollection<string> Hotkeys { get { return new ReadOnlyObservableCollection<string>(_hotkeys); } } public string Title { get { return _title; } set { _title = value; OnPropertyChanged(() => Title); } } protected override void OnDispose() { base.OnDispose(); _hotkeyManager.Dispose(); _focusManager.Dispose(); } private void FocusManager_Focus(object sender, FocusManagerEventArgs e) { Title = e.Title; } private void HotkeyManager_NewHotkey(object sender, EventArgs eventArgs) { HotkeysForeground = _hotkeys.Count <= 2 ? Colors.Blue : Colors.Brown; _hotkeys.Clear(); foreach (var hotkey in _hotkeyManager.GetHotkeys()) { _hotkeys.Add(hotkey); } } } } Here is the view. <Window x:Class="Monkey.View.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib" Title="{Binding Mode=OneWay, Path=Title, UpdateSourceTrigger=PropertyChanged}" Height="200" Width="200" ShowInTaskbar="False" WindowStyle="ToolWindow" Topmost="True" ResizeMode="CanResizeWithGrip" AllowsTransparency="False"> <Window.Resources> <SolidColorBrush Color="{Binding HotkeysForeground}" x:Key="HotkeysBrush"/> </Window.Resources> <ListBox Canvas.Left="110" Canvas.Top="74" Name="HotkeyList" Height="Auto" Width="Auto" HorizontalContentAlignment="Left" BorderThickness="0" ScrollViewer.CanContentScroll="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemsSource="{Binding Path=Hotkeys}" VerticalAlignment="Stretch" VerticalContentAlignment="Center" FontSize="20"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="IsEnabled" Value="False" /> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemTemplate> <DataTemplate> <Label Content="{Binding}" Foreground="{StaticResource HotkeysBrush}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Window> Thank you in advance.

    Read the article

  • Is there a clean separation of my layers with this attempt at Domain Driven Design in XAML and C#

    - by Buddy James
    I'm working on an application. I'm using a mixture of TDD and DDD. I'm working hard to separate the layers of my application and that is where my question comes in. My solution is laid out as follows Solution MyApp.Domain (WinRT class library) Entity (Folder) Interfaces(Folder) IPost.cs (Interface) BlogPosts.cs(Implementation of IPost) Service (Folder) Interfaces(Folder) IDataService.cs (Interface) BlogDataService.cs (Implementation of IDataService) MyApp.Presentation(Windows 8 XAML + C# application) ViewModels(Folder) BlogViewModel.cs App.xaml MainPage.xaml (Contains a property of BlogViewModel MyApp.Tests (WinRT Unit testing project used for my TDD) So I'm planning to use my ViewModel with the XAML UI I'm writing a test and define my interfaces in my system and I have the following code thus far. [TestMethod] public void Get_Zero_Blog_Posts_From_Presentation_Layer_Returns_Empty_Collection() { IBlogViewModel viewModel = _container.Resolve<IBlogViewModel>(); viewModel.LoadBlogPosts(0); Assert.AreEqual(0, viewModel.BlogPosts.Count, "There should be 0 blog posts."); } viewModel.BlogPosts is an ObservableCollection<IPost> Now.. my first thought is that I'd like the LoadBlogPosts method on the ViewModel to call a static method on the BlogPost entity. My problem is I feel like I need to inject the IDataService into the Entity object so that it promotes loose coupling. Here are the two options that I'm struggling with: Not use a static method and use a member method on the BlogPost entity. Have the BlogPost take an IDataService in the constructor and use dependency injection to resolve the BlogPost instance and the IDataService implementation. Don't use the entity to call the IDataService. Put the IDataService in the constructor of the ViewModel and use my container to resolve the IDataService when the viewmodel is instantiated. So with option one the layers will look like this ViewModel(Presentation layer) - Entity (Domain layer) - IDataService (Service Layer) or ViewModel(Presentation layer) - IDataService (Service Layer)

    Read the article

  • How do I Insert Record MVVM through WCF

    - by DG KOL
    Hello, I’m new in MVVM Pattern (Using Galasoft MVVM Light toolkit). I’ve created a Test Project where I want to fetch some records from Database through WCF. This is working fine but I’ve failed to insert new record from View; Here is My Code: Database Table Name: TestUser (First Name, LastName) WCF (NWCustomer) Two Methods Public List<TestUser> GetAllUsers() [“LINQ2SQL Operation”] Public bool AddUser(TestUser testuser) Public bool AddUser(TestUser testuser) { try { using (DBDataContext db = new DBDataContext()) { TestUser test = new TestUser() { FirstName = testuser.FirstName, LastName = testuser.LastName }; db.TestUser.InsertOnSubmit(test); db.SubmitChanges(); } } catch (Exception ex) { return false; } return true; } Silverlight Project MODEL consists ITestUserService.cs TestUserService.cs public void AddTestTable(TestTableViewModel testuser, Action<bool> callback) { NWCustomerClient client = new NWCustomerClient("BasicHttpBinding_NWCustomer"); client.AddTestUserCompleted += (s, e) => { var userCallback = e.UserState as Action<bool>; if (userCallback == null) { return; } if (e.Error == null) { userCallback(e.Result); return; } userCallback(false); }; client.AddTestUserAsync(testuser.Model); } VIEWMODEL TestUserViewModel public TestUser User { get; private set; } public const string DirtyVisibilityPropertyName = "DirtyVisibility"; private Visibility _dirty = Visibility.Collapsed; public Visibility DirtyVisibility { get { return _dirty; } set { if (_dirty == value) { return; } _dirty = value; RaisePropertyChanged(DirtyVisibilityPropertyName); } } public TestUserViewModel (TestUser user) { User = user; user.PropertyChanged += (s, e) => { DirtyVisibility = Visibility.Visible; }; } MainViewModel public ObservableCollection<TestUserViewModel> TestTables { get; private set; } public const string ErrorMessagePropertyName = "ErrorMessage"; private string _errorMessage = string.Empty; public string ErrorMessage { get { return _errorMessage; } set { if (_errorMessage == value) { return; } _errorMessage = value; RaisePropertyChanged(ErrorMessagePropertyName); } } private ITestUserService _service; public RelayCommand< TestUserViewModel> AddTestUserRecord { get; private set; } public MainTestTableViewModel (ICustomerService service) { _service = service; TestTables = new ObservableCollection<TestTableViewModel>(); service.GetAllTestTable(HandleResult); } private void HandleResult(IEnumerable<TestTable> result, Exception ex) { TestTables.Clear(); if (ex != null) { //Error return; } if (result == null) { return; } foreach (var test in result) { var table = new TestTableViewModel(test); TestTables.Add(table); } } XAML <Grid x:Name="LayoutRoot"> <StackPanel> <TextBox Text="FirstName" /> <TextBox Text="LastName" /> <Button Content="Add Record" Command="{Binding AddTestUserRecord}" /> </StackPanel> </Grid> I want to add records into TestTable (Database Table). How do I insert record? In XAML two text box and a button control is present. Thanking you. DG

    Read the article

  • WP7 listbox binding not working properly

    - by Marco
    A noob error for sure (I started yesterday afternoon developing in WP7), but I'm wasting a lot time on it. I post my class and a little part of my code: public class ChronoLaps : INotifyPropertyChanged { private ObservableCollection<ChronoLap> laps = null; public int CurrentLap { get { return lap; } set { if (value == lap) return; // Some code here .... ChronoLap newlap = new ChronoLap() { // Some code here ... }; Laps.Insert(0, newlap); lap = value; NotifyPropertyChanged("CurrentLap"); NotifyPropertyChanged("Laps"); } } public ObservableCollection<ChronoLap> Laps { get { return laps; } set { if (value == laps) return; laps = value; if (laps != null) { laps.CollectionChanged += delegate { MeanTime = Laps.Sum(p => p.Time.TotalMilliseconds) / (Laps.Count * 1000); NotifyPropertyChanged("MeanTime"); }; } NotifyPropertyChanged("Laps"); } } } MainPage.xaml.cs public partial class MainPage : PhoneApplicationPage { public ChronoLaps History { get; private set; } private void butStart_Click(object sender, EventArgs e) { History = new ChronoLaps(); // History.Laps.Add(new ChronoLap() { Distance = 0 }); LayoutRoot.DataContext = History; } } MainPage.xaml <phone:PhoneApplicationPage> <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid Grid.Row="2"> <ScrollViewer Margin="-5,13,3,36" Height="758"> <ListBox Name="lbHistory" ItemContainerStyle="{StaticResource ListBoxStyle}" ItemsSource="{Binding Laps}" HorizontalAlignment="Left" Margin="5,25,0,0" VerticalAlignment="Top" Width="444"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Lap}" Width="40" /> <TextBlock Text="{Binding Time}" Width="140" /> <TextBlock Text="{Binding TotalTime}" Width="140" /> <TextBlock Text="{Binding Distance}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </ScrollViewer> </Grid> </Grid> </phone:PhoneApplicationPage> Problem is that when I add one or more items to History.Laps collection, my listbox is not refreshed and these items don't appear. But if I remove comment on // History.Laps.Add(new ChronoLap()... line, this item appear and so every other inserted later. More: if I remove that comment and then write History.Laps.Clear() (before or after setting binding) binding is not working anymore. It's like it gets crazy if collection is empty. I really don't understand the reason... UPDATE AND SOLUTION: If i move History = new ChronoLaps(); LayoutRoot.DataContext = History; from butStart_Click to public MainPage() everything works as expected. Can someone explain me the reason?

    Read the article

  • CodePlex Daily Summary for Tuesday, June 14, 2011

    CodePlex Daily Summary for Tuesday, June 14, 2011Popular ReleasesSizeOnDisk: 1.0.9.0: Can handle Right-To-Left languages (issue 316) About box (issue 310) New language: Deutsch (thanks to kyoka) Fix: file and folder context menuTerrariViewer: TerrariViewer v2.6: This is a temporary release so that people can edit their characters for the newest version of Terraria. It does not include the newest items or the ability to add social slot items. Those will come in TerrariViewer v3.0, which I am currently working on.DropBox Linker: DropBox Linker 1.1: Added different popup descriptions for actions (copy/append/update/remove) Added popup timeout control (with live preview) Added option to overwrite clipboard with the last link only Notification popup closes on user click Notification popup default timeout increased to 3 sec. Added codeplex link to about .NET Framework 4.0 Client Profile requiredMobile Device Detection and Redirection: 1.0.4.1: Stable Release 51 Degrees.mobi Foundation is the best way to detect and redirect mobile devices and their capabilities on ASP.NET and is being used on thousands of websites worldwide. We’re highly confident in our software and we recommend all users update to this version. Changes to Version 1.0.4.1Changed the BlackberryHandler and BlackberryVersion6Handler to have equal CONFIDENCE values to ensure they both get a chance at detecting BlackBerry version 4&5 and version 6 devices. Prior to thi...Kouak - HTTP File Share Server: Kouak Beta 3 - Clean: Some critical bug solved and dependecy problems There's 3 package : - The first, contains the cli server and the graphical server. - The second, only the cli server - The third, only the graphical client. It's a beta release, so don't hesitate to emmit issue ;pRawr: Rawr 4.1.06: This is the Downloadable WPF version of Rawr!For web-based version see http://elitistjerks.com/rawr.php You can find the version notes at: http://rawr.codeplex.com/wikipage?title=VersionNotes Rawr AddonWe now have a Rawr Official Addon for in-game exporting and importing of character data hosted on Curse. The Addon does not perform calculations like Rawr, it simply shows your exported Rawr data in wow tooltips and lets you export your character to Rawr (including bag and bank items) like Char...AcDown????? - Anime&Comic Downloader: AcDown????? v3.0 Beta6: ??AcDown?????????????,?????????????,????、????。?????Acfun????? ????32??64? Windows XP/Vista/7 ????????????? ??:????????Windows XP???,?????????.NET Framework 2.0???(x86)?.NET Framework 2.0???(x64),?????"?????????"??? ??v3.0 Beta6 ?????(imanhua.com)????? ???? ?? ??"????","?????","?????","????"?????? "????"?????"????????"?? ??????????? ?????????????? ?????????????/???? ?? ????Windows 7???????????? ????????? ?? ????????????? ???????/??????????? ???????????? ?? ?? ?????(imanh...Microsoft Ajax Minifier: Microsoft Ajax Minifier 4.22: Added lots of optimizations related to expression optimization. Combining adjacent expression statements into a single statement means more if-, for-, and while-statements can get rid of the curly-braces. Then more if-statements can be converted to expressions, and more expressions can be combined with return- and for-statements. Moving functions to the top of their scopes, followed by var-statements, provides more opportunities for expression-combination. Added command-line option to remove ...Pulse: Pulse Beta 2: - Added new wallpapers provider http://wallbase.cc. Supports english search, multiple keywords* - Improved font rendering in Options window - Added "Set wallpaper as logon background" option* - Fixed crashes if there is no internet connection - Fixed: Rewalls downloads empty images sometimes - Added filters* Note 1: wallbase provider supports only english search. Rewalls provider supports only russian search but Pulse automatically translates your english keyword into russian using Google Tr...???? (Internet Go Game for Android): goapp.3.0.apk: Refresh UI and bugfixPhalanger - The PHP Language Compiler for the .NET Framework: 2.1 (June 2011) for .NET 4.0: Release of Phalanger 2.1 - the opensource PHP compiler for .NET framework 4.0. Installation package also includes basic version of Phalanger Tools for Visual Studio 2010. This allows you to easily create, build and debug Phalanger web or application inside this ultimate integrated development environment. You can even install the tools into the free Visual Studio 2010 Shell (Integrated). To improve the performance of your application using MySQL, please use Managed MySQL Extension for Phala...WPF Application Framework (WAF): WPF Application Framework (WAF) 2.0.0.7: Version: 2.0.0.7 (Milestone 7): This release contains the source code of the WPF Application Framework (WAF) and the sample applications. Requirements .NET Framework 4.0 (The package contains a solution file for Visual Studio 2010) The unit test projects require Visual Studio 2010 Professional Remark The sample applications are using Microsoft’s IoC container MEF. However, the WPF Application Framework (WAF) doesn’t force you to use the same IoC container in your application. You can use ...SimplePlanner: v2.0b: For 2011-2012 Sem 1 ???2011-2012 ????Visual Studio 2010 Help Downloader: 1.0.0.3: Domain name support for proxy Cleanup old packages bug Writing to EventLog with UAC enabled bug Small fixes & Refactoring32feet.NET: 3.2: 32feet.NET v3.2 - Personal Area Networking for .NET Build 3.2.0609.0 9th June 2011 This library provides a .NET networking API for devices and desktop computers running the Microsoft or Broadcom/Widcomm Bluetooth stacks, Microsoft Windows supported IrDA devices and associated Object Exchange (OBEX) services for both these mediums. Online documentation is integrated into your Visual Studio help. The object model has been designed to promote consistency between Bluetooth, IrDA and traditional ...Media Companion: MC 3.406b weekly: With this version change a movie rebuild is required when first run -else MC will lock up on exit. Extract the entire archive to a folder which has user access rights, eg desktop, documents etc. Refer to the documentation on this site for the Installation & Setup Guide Important! If you find MC not displaying movie data properly, please try a 'movie rebuild' to reload the data from the nfo's into MC's cache. Fixes Movies Readded movie preference to rename invalid or scene nfo's to info ext...Windows Azure VM Assistant: AzureVMAssist V1.0.0.5: AzureVMAssist V1.0.0.5 (Debug) - Test Release VersionNetOffice - The easiest way to use Office in .NET: NetOffice Release 0.9: Changes: - fix examples (include issue 16026) - add new examples - 32Bit/64Bit Walkthrough is now available in technical Documentation. Includes: - Runtime Binaries and Source Code for .NET Framework:......v2.0, v3.0, v3.5, v4.0 - Tutorials in C# and VB.Net:..............................................................COM Proxy Management, Events, etc. - Examples in C# and VB.Net:............................................................Excel, Word, Outlook, PowerPoint, Access - COMAddi...Reusable Library: V1.1.3: A collection of reusable abstractions for enterprise application developerVidCoder: 0.9.2: Updated to HandBrake 4024svn. This fixes problems with mpeg2 sources: corrupted previews, incorrect progress indicators and encodes that incorrectly report as failed. Fixed a problem that prevented target sizes above 2048 MB.New ProjectsASP.NET MVC / Windows Workflow Foundation Integration: This project will product libraries, activities and examples that demonstrate how you can use Windows Workflow Foundation with ASP.NET MVCBing Maps Spatial Data Service Loader: Bing Maps Spatial Data Service Loader is a simple tool that helps you to load your set of data (CSV) into the Spatial Data Service included in Bing Maps licensing.Blend filter and Pencil sketch effect in C#: This project contains a filter for blending one image over an other using effects like Color Dodge, Lighten, Darken, Difference, etc. And an example of how to use that to do a Pencil Sketch effect in C# using AForge frameworkBugStoryV2: student project !CAIXA LOTERIAS: Projeto destinado a integrar resultado dos sorteios da Caixa em VB.NET, C#, ASP.NETCSReports: Report authoring tool. It supports dinamyc grouping, scripting formulas in vbscript, images from db and sub-sections. The report definition is saved to file in xml format and can be exported to pdf, doc and xls format.EasyLibrary: EasyLibraryFreetime Development Platform: Freetime Development Platform is a set of reusable design used to develop Web and Desktop based applications. IISProcessScheduler: Schedule processes from within IIS.LitleChef: LitleChefLLBLGen ANGTE (ASP.Net GUI Templates Extended): LLBLGen ANGTE (ASP.Net GUI Templates Extended) makes possible to use LLBLGen template system to generate a reasonable ASP.Net GUI that you can use as the base of your project or just as a prototyping tool. It generates APS.Net code with C# as code behind using .Net 2.0Memory: Memory Game for AndroidNCU - Book store: Educational project for a software engineering bootcamp at Northern Caribbean UniversityOrderToList Extension for IEnumerable: An extension method for IEnumerable<T> that will sort the IEnumerable based on a list of keys. Suppose you have a list of IDs {10, 5, 12} and want to use LINQ to retrieve all People from the DB with those IDs in that order, you want this extension. Sort is binary so it's fastp301: Old project.Pang: A new pong rip off; including some power ups. Will be written in C# using XNA.Ring2Park Online: Ring2Park is a fully working ASP.NET reference application that simulates the online purchase and management of Vehicle Parking sessions. It is developed using the latest ASP.NET MVC 3 patterns and capabilities. It includes a complete set of Application Lifecycle Management (ALM) assets, including requirements, test and deployment.rITIko: Questo progetto è stato creato come esperimento dalla classe 4G dell'ITIS B. Pascal di Cesena. Serve (per ora) solo per testate il funzionamento di CodePlex e del sistema SVN. Forse un giorno conterrà qualcosa di buono, rimanete aggiornati.Rug.Cmd - Command Line Parser and Console Application Framework: Rugland Console Framework is a collection of classes to enable the fast and consistent development of .NET console applications. Parse command line arguments and write your applications usage. If you are developing command line or build process tools in .NET then this maybe the lightweight framework for you. It is developed in C#.SamaToursUSA: sama tours usaSamcrypt: .Security System: With this program you will be able to secure your screen from prying eyes. In fact as soon as the block will not be unlocked only with your password. Perfect for when you go to have a coffee in the break. :)Sharp Temperature Conversor: Sharp Temperature Conversor has the objective of providing a easy, fast and a direct way to convert temperatures from one type to another. The project is small, uses C#, Visual Studio 2010. The project is small. However, the growth is possible. Silverlight Star Rating Control: A simple star rating control for editing or displaying ratings in Silverlight. Supports half-filled stars. Includes the star shape as a separate control.Silverware: Silverware is a set of libraries to enhance and make application development in Silverlight easier.Simple & lightweight fluent interface for Design by Contract: This project try to focus on make a good quality code for your project. It try to make sure all instance and variables must be satisfy some conditions in Design by Contract.SimpleAspect: A simple Aspect library for PostSharpTespih: Basit tespih uygulamasi. Kendi evrad u ezkar listenizi olusturup seçtiginiz bir evrat üzerinden tespih çekebilirsiniz.Texticize: Texticize is a fast, extensible, and intuitive object-to-text template engine for .NET. You can use Texticize to quickly create dynamic e-mails, letters, source code, or any other text documents using predefined text templates substituting placeholders with properties of CLR objects in realtime.The Dragon riders: a mmorgh game with free play in creaction. FantasyWPF ObservableCollection: WPF ObservableCollection Idle use.X9.37 Image Cash Letter file viewer: x9.37 Image Cash Letter viewer. Developed using VB.Net. Currently allows viewing and searching of X9 files. The code also has image manipulation code, specifically multi page TIF file handling that you might find useful,

    Read the article

  • Binding the position and size of a UserControl inside a Canvas in WPF

    - by John
    Hi. We have dynamically created (i.e. during runtime, via code-behind) UserControls inside a Canvas. We want to bind the position (Canvas.Left and Canvas.Top) and width of those sizable and draggable UserControls to a ObservableCollection<. How would we achieve this if the Usercontrol is contained in a DataTemplate which in turn is used by a ListBox whose DataContext is set to the collection we want to bind to? In other words, how do we bind a control's position and size that doesn't exist in XAML, but in code only (because it's created by clicking and dragging the mouse)? Notice that the collection can be empty or not empty, meaning that the size and position stores in a collection item must be correctly bound to so that the UserControl can be sized and positioned correctly in the Canvas - via DataBinding. Is this possible?

    Read the article

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