Search Results

Search found 16824 results on 673 pages for 'model binding'.

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

  • MVVM - ListBox SelectedItem Binding Property Going Null

    - by Peanut
    So i have a listbox: <ListBox x:Name="listbox" HorizontalAlignment="Left" Margin="8,8,0,8" Width="272" BorderBrush="{x:Null}" Background="{x:Null}" Foreground="{x:Null}" ItemsSource="{Binding MenuItems}" ItemTemplate="{DynamicResource MenuItemsTemplate}" SelectionChanged="ListBox_SelectionChanged" SelectedItem="{Binding SelectedItem}"> </ListBox> and i have this included in my viewmodel: public ObservableCollection<MenuItem> MenuItems { get { return menuitems; } set { menuitems = value; NotifyPropertyChanged("MenuItems"); } } public MenuItem SelectedItem { get { return selecteditem; } set { selecteditem = value; NotifyPropertyChanged("SelectedItem"); } } and also in my viewmodel: public void UpdateStyle() { ActiveHighlight = SelectedItem.HighlightColor; ActiveShadow = SelectedItem.ShadowColor; } So, the objective is to call UpdateStyle() whenever selectedchanged event is fired. So in the .CS file, i call UpdateStyle(). The problem is, whenever I get into the selectionchanged event method, my ViewModel.SelectedItem is always null. I tried debugging this to see if the binding was working correctly, and it is. When I click on an item in the listbox, the SelectedItem Set is triggered, setting the value... but somewhere inbetween that and the selected changed (In the CS File) It gets reset to Null. Can anyone help out? Thanks

    Read the article

  • wpf datagrid current item binding

    - by tk
    I want to bind a content of Label to the selected item of a datagrid. I thought the 'current item' binding expression would work, but it is not. My xaml code and code-behind c# is like below. <Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="512" Width="847"> <DockPanel LastChildFill="True"> <Label Content="{Binding Data/colA}" DockPanel.Dock="Top" Height="30"/> <DataGrid ItemsSource="{Binding Data}"></DataGrid> </DockPanel> </Window> namespace WpfApplication2 { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.DataContext = new MyData(); } } public class MyData { DataTable data; public MyData() { data = new DataTable(); data.Columns.Add("colA"); data.Columns.Add("colB"); data.Rows.Add("aa", 1); data.Rows.Add("bb", 2); } public DataTable Data { get { return data; } } } } The label shows the first item of the DataTable, and does not change when i select other items on the datagrid. It seems the current item of dataview does not change. What should i do to bind it to the current selected item of datagrid?

    Read the article

  • Binding a TreeView with ContextMenu in Xaml

    - by Michael Stoll
    I'm pretty new to Xaml and need some advise. A TreeView should be bound to a hierarchical object structure. The TreeView should have a context menu, which is specific for each object type. I've tried the following: <TreeView> <TreeView.Resources> <DataTemplate x:Key="RoomTemplate"> <TreeViewItem Header="{Binding Name}"> <TreeViewItem.ContextMenu> <ContextMenu> <MenuItem Header="Open" /> <MenuItem Header="Remove" /> </ContextMenu> </TreeViewItem.ContextMenu> </TreeViewItem> </DataTemplate> </TreeView.Resources> <TreeViewItem Header="{Binding Name}" Name="tviRoot" IsExpanded="True" > <TreeViewItem Header="Rooms" ItemsSource="{Binding Rooms}" ItemTemplate="{StaticResource RoomTemplate}"> <TreeViewItem.ContextMenu> <ContextMenu> <MenuItem Header="Add room"></MenuItem> </ContextMenu> </TreeViewItem.ContextMenu> </TreeViewItem> </TreeViewItem> But with this markup the behavior is as intended, but the child items (the rooms) are indented too much. Anyway all the bining samples I could find use TextBlock instead of TreeViewItem in the DataTemplate, but wonder how to integrate the ContextMenu there.

    Read the article

  • WPF UserControl weird binding problem

    - by Heko
    Hello! Im usign a Ribbon Window and in the "content area beneath" I have a grid in which I will be displaying UserControls. To demonstrate my problem lets take a look at this simple UserControl: <ListView x:Name="lvPersonList"> <ListView.View> <GridView> <GridViewColumn Width="120" Header="Name" DisplayMemberBinding="{Binding Name}"/> <GridViewColumn Width="120" Header="Height" DisplayMemberBinding="{Binding Height}"/> </GridView> </ListView.View> </ListView> And the code: public partial class MyUserControl: UserControl { private List<Person> personList; public TestSnpList() { InitializeComponent(); this.personList = new List<Person>(); this.personList.Add(new Person { Name = "Chuck Norris", Height = 210 }); this.personList.Add(new Person { Name = "John Rambo", Height = 200 }); this.lvPersonList.ItemsSource = personList; } } public class Person { public string Name { get; set; } public int Height { get; set; } } The parent Window: <Grid x:Name="grdContent" DockPanel.Dock="Top"> <controls:MyUserControl x:Name="myUserControl" Visibility="Visible"/> </Grid> I don't understant why this binding doesn't work. Instead of values (Name and Height) I get full class names. If I use this code in a Window it works fine. Any ideas? I would like this user contorl works for itself (it gets the data form the DB and represents it in a ListView)... Thanks!

    Read the article

  • Binding Data to a TextBlock using Domain Data Source

    - by TFisher
    I have a map with hotspots for each state (done in Expression Blend). I capture each MouseEnter of the state (1 thru 50). I pass that into my Domain Data Source: Dim activebox As Path = TryCast(sender, Path) activebox.Fill = mouseOverColor Dim StateID As Integer = CInt(Right(activebox.Name, 2)) Dim _StateContext As New StateContext myDataGrid.ItemsSource = _StateContext.States _StateContext.Load(_StateContext.GetStateByStateIDQuery(StateID.Text)) The above works fine for a datagrid, listbox and even a dataform. But I created a popup with a stackpanel that has textblocks. popupStatesBox.DataContext = ?????????????? popupStatesBox.IsOpen = True 'popup does open but has no data -- popupStatesBox.xaml <Popup x:Name="popupStatsBox" Margin="8,35,0,8" DataContext="{Binding}" IsOpen="false" Width="268" HorizontalAlignment="Left"> <StackPanel x:Name="Layout" Background="Black"> <TextBlock x:Name="tbState" Text="{Binding StateName /> <TextBlock x:Name="tbAbbrev" Text="{Binding Abbreviation}" /> </StackPanel> </Popup> How do I get the textblocks to display the values from the _StateContext. StackPanel has DataContext but no ItemsSource. What am I missing?

    Read the article

  • Valueurl Binding On Large Arrays Causes Sluggish User Interface

    - by Hooligancat
    I have a large data set (some 3500 objects) that returns from a remote server via HTTP. Currently the data is being presented in an NSCollectionView. One aspect of the data is a path pack to the server for a small image that represents the data (think thumbnail for simplicity). Bindings works fantastically for the data that is already returned, and binding the image via a valueurl binding is easy to do. However, the user interface is very sluggish when scrolling through the data set - which makes me think that the NSCollectionView is retrieving all the image data instead of just the image data used to display the currently viewable images. I was under the impression that Cocoa controls were smart enough to only retrieve data for the information that is actually being output to the user interface through lazy loading. This certainly seems to be the case with NSTableView - but I could be misguided on this thought. Should valueurl binding act lazily and, moreover, should it act lazily in an NSCollectionView? I could create a caching mechanism (in fact I already have such a thing in place for another application - see my post here if you are interested http://stackoverflow.com/questions/1740209/populating-nsimage-with-data-from-an-asynchronous-nsurlconnection) but I really don't want to go this route if I don't have to for this specific implementation as the user could potentially change data sets often and may only want small sub-sets of the data. Any suggested approaches? Thanks!

    Read the article

  • MyContainer derived from FrameworkElement with binding support.

    - by alex2k8
    To understand how the binding works, I implemented MyContainer derived from FrameworkElement. This container allowes to set Children and adds them into the logical tree. But the binding by ElementName does not work. What can I do with MyContainer to make it work, leaving the parent as FrameworkElement? C#: public class MyContainer : FrameworkElement { public MyContainer() { Children = new List<FrameworkElement>(); } public List<FrameworkElement> Children { get; set; } protected override IEnumerator LogicalChildren { get { return Children.GetEnumerator(); } } } XAML: <Window x:Class="WpfLogicalTree.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfLogicalTree" Title="Window1" Height="300" Width="300"> <StackPanel> <local:MyContainer> <local:MyContainer.Children> <TextBlock Text="Foo" x:Name="_source" /> <TextBlock Text="{Binding Path=Text, ElementName=_source}" x:Name="_target"/> </local:MyContainer.Children> </local:MyContainer> <Button Click="Button_Click">Test</Button> </StackPanel> </Window> Window1.cs private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show(_target.Text); }

    Read the article

  • Problems with binding to Window Height and Width

    - by D.H.
    I have some problems when I try to bind the height and width of a window to properties in my view model. Here is a small sample app to illustrate the problem. This is the code in app.xaml.xs public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWindow mainWindow = new MainWindow(); MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(); mainWindow.DataContext = mainWindowViewModel; mainWindow.Show(); } } This is MainWindow.xaml: <Window x:Class="TestApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="{Binding WindowHeight}" Width="{Binding WindowWidth}" BorderThickness="{Binding WindowBorderThickness}"> </Window> And this is the view model: public class MainWindowViewModel { public int WindowWidth { get { return 100; } } public int WindowHeight { get { return 200; } } public int WindowBorderThickness { get { return 8; } } } When the program is started the getters of WindowHeight and WindowBorderThickness (but not WindowWidth) are called, so the height and the border of the window is set properly, but not the width. I then add button that will trigger PropertyChanged for all properties, so that the view model now looks like this: public class MainWindowViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public void TriggerPropertyChanges() { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("WindowWidth")); PropertyChanged(this, new PropertyChangedEventArgs("WindowHeight")); PropertyChanged(this, new PropertyChangedEventArgs("WindowBorderThickness")); } } public ICommand ButtonCommand { get { return new RelayCommand(delegate { TriggerPropertyChanges(); }); } } public int WindowWidth { get { return 100; } } public int WindowHeight { get { return 200; } } public int WindowBorderThickness { get { return 8; } } } Now, when I click the button, the getter of WindowBorderThickness is called, but not the ones for WindowWidth and WindowHeight. It all just seems very weird and inconsistent to me. What am I missing?

    Read the article

  • Binding a TextBox's Width to its parent container's ActualWidth

    - by Praetorian
    Hi, I'm loading a Textbox and a Button into a horizontal StackPanel programmatically. The size of the button (which only contains an Image) is fixed, but I can't get the textbox to fill the available width of its parent. This is what the code looks like: StackPanel parent = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, }; TextBox textbox = new TextBox() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, //MinWidth = 375, }; Button btn = new Button() { Content = new Image() { MaxHeight = 40, MaxWidth = 40, MinHeight = 40, MinWidth = 40, Margin = new Thickness( 0 ), Source = new BitmapImage( new Uri( "btnimage.png", UriKind.Relative ) ), }, HorizontalAlignment = HorizontalAlignment.Right, BorderBrush = new SolidColorBrush( Colors.Transparent ), Margin = new Thickness( 0 ), }; btn.Click += ( ( s, e ) => OnBtnClicked( s, e, textbox ) ); parent.Children.Add( textbox ); parent.Children.Add( btn ); If I uncomment the MinWidth setting for the textbox it is displayed as I want it to, but I'd like to not have to specify a width explicitly. I tried adding a binding as follows but that doesn't work at all (the textbox just disappears!) Binding widthBinding = new Binding() { Source = parent.ActualWidth, }; passwdBox.SetBinding( TextBox.WidthProperty, widthBinding ); Thanks for your help in advance!

    Read the article

  • MVC4 Model in View has nested data - cannot get data in model

    - by Taersious
    I have a Model defined that gets me a View with a list of RadioButtons, per IEnumerable. Within that Model, I want to display a list of checkboxes that will vary based on the item selected. Finally, there will be a Textarea in the same view once the user has selected from the available checkboxes, with some dynamic text there based on the CheckBoxes that are selected. What we should end up with is a Table-per-hierarchy. The layout is such that the RadioButtonList is in the first table cell, the CheckBoxList is in the middle table cell, and the Textarea is ini the right table cell. If anyone can guide me to what my model-view should be to achieve this result, I'll be most pleased... Here are my codes: // // View Model for implementing radio button list public class RadioButtonViewModel { // objects public List<RadioButtonItem> RadioButtonList { get; set; } public string SelectedRadioButton { get; set; } } // // Object for handling each radio button public class RadioButtonItem { // this object public string Name { get; set; } public bool Selected { get; set; } public int ObjectId { get; set; } // columns public virtual IEnumerable<CheckBoxItem> CheckBoxItems { get; set; } } // // Object for handling each checkbox public class CheckBoxViewModel { public List<CheckBoxItem> CheckBoxList { get; set; } } // // Object for handling each check box public class CheckBoxItem { public string Name { get; set; } public bool Selected { get; set; } public int ObjectId { get; set; } public virtual RadioButtonItem RadioButtonItem { get; set; } } and the view @model IEnumerable<EF_Utility.Models.RadioButtonItem> @{ ViewBag.Title = "Connect"; ViewBag.Selected = Request["name"] != null ? Request["name"].ToString() : ""; } @using (Html.BeginForm("Objects" , "Home", FormMethod.Post) ){ @Html.ValidationSummary(true) <table> <tbody> <tr> <td style="border: 1px solid grey; vertical-align:top;"> <table> <tbody> <tr> <th style="text-align:left; width: 50px;">Select</th> <th style="text-align:left;">View or Table Name</th> </tr> @{ foreach (EF_Utility.Models.RadioButtonItem item in @Model ) { <tr> <td> @Html.RadioButton("RadioButtonViewModel.SelectedRadioButton", item.Name, ViewBag.Selected == item.Name ? true : item.Selected, new { @onclick = "this.form.action='/Home/Connect?name=" + item.Name + "'; this.form.submit(); " }) </td> <td> @Html.DisplayFor(i => item.Name) </td> </tr> } } </tbody> </table> </td> <td style="border: 1px solid grey; width: 220px; vertical-align:top; @(ViewBag.Selected == "" ? "display:none;" : "")"> <table> <tbody> <tr> <th>Column </th> </tr> <tr> <td><!-- checkboxes will go here --> </td> </tr> </tbody> </table> </td> <td style="border: 1px solid grey; vertical-align:top; @(ViewBag.Selected == "" ? "display:none;" : "")"> <textarea name="output" id="output" rows="24" cols="48"></textarea> </td> </tr> </tbody> </table> } and the relevant controller public ActionResult Connect() { /* TEST SESSION FIRST*/ if( Session["connstr"] == null) return RedirectToAction("Index"); else { ViewBag.Message = ""; ViewBag.ConnectionString = Server.UrlDecode( Session["connstr"].ToString() ); ViewBag.Server = ParseConnectionString( ViewBag.ConnectionString, "Data Source" ); ViewBag.Database = ParseConnectionString( ViewBag.ConnectionString, "Initial Catalog" ); using( var db = new SysDbContext(ViewBag.ConnectionString)) { var objects = db.Set<SqlObject>().ToArray(); var model = objects .Select( o => new RadioButtonItem { Name = o.Name, Selected = false, ObjectId = o.Object_Id, CheckBoxItems = Enumerable.Empty<EF_Utility.Models.CheckBoxItem>() } ) .OrderBy( rb => rb.Name ); return View( model ); } } } What I am missing it seems, is the code in my Connect() method that will bring the data context forward; at that point, it should be fairly straight-forward to set up the Html for the View. EDIT ** So I am going to need to bind the RadioButtonItem to the view with something like the following, except my CheckBoxList will NOT be an empty set. // // POST: /Home/Connect/ [HttpPost] public ActionResult Connect( RadioButtonItem rbl ) { /* TEST SESSION FIRST*/ if ( Session["connstr"] == null ) return RedirectToAction( "Index" ); else { ViewBag.Message = ""; ViewBag.ConnectionString = Server.UrlDecode( Session["connstr"].ToString() ); ViewBag.Server = ParseConnectionString( ViewBag.ConnectionString, "Data Source" ); ViewBag.Database = ParseConnectionString( ViewBag.ConnectionString, "Initial Catalog" ); using ( var db = new SysDbContext( ViewBag.ConnectionString ) ) { var objects = db.Set<SqlObject>().ToArray(); var model = objects .Select( o => new RadioButtonItem { Name = o.Name, Selected = false, ObjectId = o.Object_Id, CheckBoxItems = Enumerable.Empty<EF_Utility.Models.CheckBoxItem>() } ) .OrderBy( rb => rb.Name ); return View( model ); } } }

    Read the article

  • design a model for a system of dependent variables

    - by dbaseman
    I'm dealing with a modeling system (financial) that has dozens of variables. Some of the variables are independent, and function as inputs to the system; most of them are calculated from other variables (independent and calculated) in the system. What I'm looking for is a clean, elegant way to: define the function of each dependent variable in the system trigger a re-calculation, whenever a variable changes, of the variables that depend on it A naive way to do this would be to write a single class that implements INotifyPropertyChanged, and uses a massive case statement that lists out all the variable names x1, x2, ... xn on which others depend, and, whenever a variable xi changes, triggers a recalculation of each of that variable's dependencies. I feel that this naive approach is flawed, and that there must be a cleaner way. I started down the path of defining a CalculationManager<TModel> class, which would be used (in a simple example) something like as follows: public class Model : INotifyPropertyChanged { private CalculationManager<Model> _calculationManager = new CalculationManager<Model>(); // each setter triggers a "PropertyChanged" event public double? Height { get; set; } public double? Weight { get; set; } public double? BMI { get; set; } public Model() { _calculationManager.DefineDependency<double?>( forProperty: model => model.BMI, usingCalculation: (height, weight) => weight / Math.Pow(height, 2), withInputs: model => model.Height, model.Weight); } // INotifyPropertyChanged implementation here } I won't reproduce CalculationManager<TModel> here, but the basic idea is that it sets up a dependency map, listens for PropertyChanged events, and updates dependent properties as needed. I still feel that I'm missing something major here, and that this isn't the right approach: the (mis)use of INotifyPropertyChanged seems to me like a code smell the withInputs parameter is defined as params Expression<Func<TModel, T>>[] args, which means that the argument list of usingCalculation is not checked at compile time the argument list (weight, height) is redundantly defined in both usingCalculation and withInputs I am sure that this kind of system of dependent variables must be common in computational mathematics, physics, finance, and other fields. Does someone know of an established set of ideas that deal with what I'm grasping at here? Would this be a suitable application for a functional language like F#? Edit More context: The model currently exists in an Excel spreadsheet, and is being migrated to a C# application. It is run on-demand, and the variables can be modified by the user from the application's UI. Its purpose is to retrieve variables that the business is interested in, given current inputs from the markets, and model parameters set by the business.

    Read the article

  • How to update model?

    - by Alexander Efimov
    Hi, guys. I have an ASP.NET MVC page where the model is being edited. On each action executing I have a new controller, so I don't get an updated model. I'm saving a model instance into Session["MyModelKey"]. But every time an action is executed, I have unmodified instance there even if I have changed values in textboxes which were created like this: @Html.LabelFor(model = model.EMail) @Html.TextBoxFor(model = model.EMail) @Html.LabelFor(model = model.Country) @Html.TextBoxFor(model = model.Country) @Html.ActionLink("MyAction", "MyController") Controller: public class MyController : Controller { public ActionResult MyAction() { //Every time this action is executed - I have a new controller instance //So I have null in View.Model //I get Session["MyModelKey"] here, //But the model instance properties are not updated //even though I have updated E-mail and Country properties of the model in the UI } } So, how can I get an updated model? Thanks in advance.

    Read the article

  • Determine if count of related model > 0

    - by Lowgain
    I have a model called Stem. I need a 'thumbs up' feature, so I have created a second model called Thumb, which consists of stem_id and user_id. I'm also using the restful authentication plugin for user credentials. I have the 'thumbs up' button working, which adds a row to the thumbs table fine, but I'd like to be able to check if the currently logged in user has already given a thumbs up to this particular stem. I tried adding this to the Stem model: def thumbed Thumb.count_by_sql ["SELECT COUNT(*) FROM thumbs WHERE user_id = ? AND stem_id = ?", current_user.id, self.id ] end The problem here is that the stem model has no access to the current_user variable the the controllers have. Is there a way I can get access to this property, or alternatively, is there another way I could go about checking this? I was hoping to get this as a property in the model because the stems are passed over to a Flex app using RubyAMF. Thanks!

    Read the article

  • Selecting Entity Data Model Laguage -- Visual C# source file generated even when i select VB

    - by Nickson
    Am adding an Entity Data Model to an ASP.NET website. When i Add New Item to the website and select ADO.NET Entity Data Model, am asked for the model name and language. I go a head and select Visual Basic as the language, the model is added and the site can compile with out any issues. however, the model it adds a ModelName.Designer.cs source file, instead of a ModelName.Designer.vb source file. am thinking this is strange as its happening with only one of my website. my other sites have .vb designer source file for their Entity Data Models. The site still compiles with out any errors but am afraid some thing is not right. any one experienced this?, is this normal behavior?

    Read the article

  • ForEach with EditorFor

    - by hermiod
    I have got an Entity model which contains a collection of Message objects which are of the type Message which has several properties, including content, MessageID, from, and to. I have created an EditorTemplate for type Message, however, I cannot get it to display the contents of the Messages collection. There are no errors, but nothing is output. Please note that the view code is from an EditorTemplate for the parent Talkback class. Can you have an EditorTemplate calling another EditorTemplate for a child collection? Both the Talkback and Message class are generated by Entity framework from an existing database. View code: <% foreach (TalkbackEntityTest.Message msg in Model.Messages) { Html.EditorFor(x=> msg, "Message"); } %> This is my template code. It is the standard auto-generated view code with some minor changes. <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TalkbackEntityTest.Message>" %> <%: Html.ValidationSummary(true) %> <fieldset> <legend>Fields</legend> <div class="editor-label"> <%: Html.LabelFor(model => model.MessageID) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.MessageID) %> <%: Html.ValidationMessageFor(model => model.MessageID) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.acad_period) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.acad_period) %> <%: Html.ValidationMessageFor(model => model.acad_period) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.talkback_id) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.talkback_id) %> <%: Html.ValidationMessageFor(model => model.talkback_id) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.From) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.From) %> <%: Html.ValidationMessageFor(model => model.From) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.To) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.To) %> <%: Html.ValidationMessageFor(model => model.To) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.SentDatetime) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.SentDatetime, String.Format("{0:g}", Model.SentDatetime)) %> <%: Html.ValidationMessageFor(model => model.SentDatetime) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.content) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.content) %> <%: Html.ValidationMessageFor(model => model.content) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.MessageTypeID) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.MessageTypeID) %> <%: Html.ValidationMessageFor(model => model.MessageTypeID) %> </div> <p> <input type="submit" value="Save" /> </p> </fieldset> There is definitely content in the Message collection as, if I remove EditorFor and put in response.write on the content property of the Message class, I get the content field for 3 Message objects on the page, which is exactly as expected.

    Read the article

  • How does one bind to a List<DataRow> collection in WPF XAML?

    - by Elan
    Using a DataTable or DataView, one can specify the binding in XAML for example as follows: <Image Source="{Binding Thumbnail}" /> In my case I have created a List collection of DataRow objects and the above is not working. This is my data source: List<DataRow> I could of course convert the List< to a DataTable, but I am curious if there was a way to specify the binding in XAML to access the "Thumbnail" column within the DataRow that is stored in a List< collection. Elan

    Read the article

  • How does one bind to an List<DataRow> collection in WPF XAML?

    - by Elan
    Using a DataTable or DataView, one can specify the binding in XAML for example as follows: <Image Source="{Binding Thumbnail}" /> In my case I have created a List collection of DataRow objects and the above is not working. This is my data source: List<DataRow> I could of course convert the List< to a DataTable, but I am curious if there was a way to specify the binding in XAML to access the "Thumbnail" column within the DataRow that is stored in a List< collection. Elan

    Read the article

  • In MVC , DAO should be called from Controller or Model

    - by tito
    I have seen various arguments against the DAO being called from the Controller class directly and also the DAO from the Model class.Infact I personally feel that if we are following the MVC pattern , the controller should not coupled with the DAO , but the Model class should invoke the DAO from within and controller should invoke the model class.Why because , we can decouple the model class apart from a webapplication and expose the functionalities for various ways like for a REST service to use our model class. If we write the DAO invocation in the controller , it would not be possible for a REST service to reuse the functionality right ? I have summarized both the approaches below. Approach #1 public class CustomerController extends HttpServlet { proctected void doPost(....) { Customer customer = new Customer("xxxxx","23",1); new CustomerDAO().save(customer); } } Approach #2 public class CustomerController extends HttpServlet { proctected void doPost(....) { Customer customer = new Customer("xxxxx","23",1); customer.save(customer); } } public class Customer { ........... private void save(Customer customer){ new CustomerDAO().save(customer); } } Note- Here is what a definition of Model is : Model: The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). In event-driven systems, the model notifies observers (usually views) when the information changes so that they can react. I would need an expert opinion on this because I find many using #1 or #2 , So which one is it ?

    Read the article

  • WPF Canvas Binding

    - by morsanu
    Hey guys, I'm rather new to WPF, so maybe this is a simple question. I have a class that derives from Canvas, let's call it MyCanvas. And I have a class, MyClass, that has a property of type MyCanvas. In XAML, I built a TabControl, so each TabItem binds to a MyClass object. Now, in the Content of every tab I want to display MyObject.MyCanvas. How should I do that? <TabControl.ContentTemplate> <DataTemplate> <Grid> <myCanvas:MyCanvas Focusable="true" Margin="10" > <Binding Path="Canvas"></Binding> </screenCanvas:ScreenCanvas> </Grid> </DataTemplate> </TabControl.ContentTemplate>

    Read the article

  • Can't get JAX-WS binding customization to work

    - by Florian
    Hi! I'm trying to resolve a name clash in a wsdl2java mapping with CXF 2.2.6 The relevant wsdl snippets are: <types>... <xs:schema... <xs:element name="GetBPK"> <xs:complexType> <xs:sequence> <xs:element name="PersonInfo" type="szr:PersonInfoType" /> <xs:element name="BereichsKennung" type="xs:string" /> <xs:element name="VKZ" type="xs:string" /> <xs:element name="Target" type="szr:FremdBPKRequestType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="ListMultiplePersons" type="xs:boolean" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="GetBPKResponse"> <xs:complexType> <xs:sequence> <xs:element name="GetBPKReturn" type="xs:string" minOccurs="0" /> <xs:element name="FremdBPK" type="szr:FremdBPKType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="PersonInfo" type="szr:PersonInfoType" minOccurs="0" maxOccurs="5" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </types> <message name="GetBPKRequest"> <part name="parameters" element="szr:GetBPK" /> </message> <message name="GetBPKResponse"> <part name="parameters" element="szr:GetBPKResponse" /> </message> <binding... <operation name="GetBPK"> <wsdlsoap:operation soapAction="" /> <input name="GetBPKRequest"> <wsdlsoap:header message="szr:Header" part="SecurityHeader" use="literal" /> <wsdlsoap:body use="literal" /> </input> <output name="GetBPKResponse"> <wsdlsoap:body use="literal" /> </output> <fault name="SZRException"> <wsdlsoap:fault use="literal" name="SZRException" /> </fault> </operation> As you can see, the GetBPK operation takes a GetBPK as input and returns a GetBPKResponse as an output. Each element of both the GetBPK, as well as the GetBPKResponse type would be mapped to a method parameter in Java. Unfortunately both GetBPK, as well as the GetBPKResponse have an element with the name "PersonInfo", which results in a name clash. I'm trying to resolve that using a binding customization: <jaxws:bindings wsdlLocation="SZ2-aktuell.wsdl" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:szr="urn:SZRServices"> <jaxws:bindings node="wsdl:definitions/wsdl:portType[@name='SZR']/wsdl:operation[@name='GetBPK']"> <!-- See page 116 of the JAX-WS specification version 2.2 from 10, Dec 2009 --> <jaxws:parameter part="wsdl:definitions/wsdl:message[@name='GetBPKResponse']/wsdl:part[@name='parameters']" childElementName="szr:PersonInfoType" name="PersonInfoParam" /> </jaxws:bindings> </jaxws:bindings> and call wsdl2java with the -b parameter. Unforunately, I still get the message: WSDLToJava Error: Parameter: personInfo already exists for method getBPK but of type at.enno.egovds.szr.PersonInfoType instead of java.util.List<at.enno.egovds.szr.PersonInfoType>. Use a JAXWS/JAXB binding customization to rename the parameter. I have tried several variants of the binding customization, and searched Google for hours, but unfortunately I cannot find a solution to my problem. I suspenct that the childElementName attribute is wrong, but I can't find an example of what would have to be set to make it work. Thanks in advance!

    Read the article

  • WPF Hide DataGridColumn via a binding

    - by Greg R
    For some reason I can't hide WPF Toolkit's DataGridColumn. I am trying to do the following: <dg:DataGridTemplateColumn Header="Item Description" Visibility="{Binding IsReadOnly}"> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding Path=ItemDescription}" /> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> This doesn't work, since it's looking for a IsReadOnly property on the ItemSource (not a property of the current class). If add this as a property of the ItemSource class that implements INoifyPropertyChanged, it still doesn't hide the column. Is there a way around this? I want the column to hid when a button click changes IsReadOnly property. Assume IsReadOnly returns a Visibility value and is a dependency property I am completely stuck, I would really appreciate the help! Thanks a lot!

    Read the article

  • Custom model binder for model inner property

    - by Andrej Kaurin
    My model is like this public class MyModel { string ID {get;set;} string Title {get;set;} MyOtherModel Meta {get;set;} } How to define custom model binder for type (MyOtherModel) so when default binder binds MyModel it calls custom model binder for 'Meta' property. I registered it in App start like: ModelBinders.Binders[typeof(MyOtherModel)] = new MyCustomBinder(); but this doesn't work. Any idea or any good article with more infor regarding to model binders?

    Read the article

  • Binding AutoCompleteBox inside DataTemplate

    - by Thiago
    I have the following AutoCompleteBox defined inside DataTemplate: <Window.Resources> <DataTemplate x:key="PaneTitleTemplate"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinition> <ContentPresenter Content="{Binding}" /> <toolkit:AutoCompleteBox x:Name="InsertBox" ItemsSource="{???}" /> </Grid> </DataTemplate> </Window.Resources> ... <radRock:RadPane x:Name="pane1" TitleTemplate="{StaticResource PaneTitleTemplate}"/> Now I'd like to fill it with a list of strings, but I don't know which Binding should I use. The list of strings is an instance variable from the Window. What should I do?

    Read the article

  • Actor model to replace the threading model?

    - by prosseek
    I read a chapter in a book (Seven languages in Seven Weeks by Bruce A. Tate) about Matz (Inventor of Ruby) saying that 'I would remove the thread and add actors, or some other more advanced concurrency features'. Why and how an actor model can be an advanced concurrency model that replaces the threading? What other models are the 'advanced concurrency model'?

    Read the article

  • WPF: Binding to ObservableCollection in ControlTemplate is not updated

    - by Julian Lettner
    I created a ControlTemplate for my custom control MyControl. MyControl derives from System.Windows.Controls.Control and defines the following property public ObservableCollection<MyControl> Children{ get; protected set; }. To display the nested child controls I am using an ItemsControl (StackPanel) which is surrounded by a GroupBox. If there are no child controls, I want to hide the GroupBox. Everything works fine on application startup: The group box and child controls are shown if the Children property initially contained at least one element. In the other case it is hidden. The problem starts when the user adds a child control to an empty collection. The GroupBox's visibility is still collapsed. The same problem occurs when the last child control is removed from the collection. The GroupBox is still visible. Another symptom is that the HideEmptyEnumerationConverter converter does not get called. Adding/removing child controls to non empty collections works as expected. Whats wrong with the following binding? Obviously it works once but does not get updated, although the collection I am binding to is of type ObservableCollection. <!-- Converter for hiding empty enumerations --> <Common:HideEmptyEnumerationConverter x:Key="hideEmptyEnumerationConverter"/> <!--- ... ---> <ControlTemplate TargetType="{x:Type MyControl}"> <!-- ... other stuff that works ... --> <!-- Child components --> <GroupBox Header="Children" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Children, Converter={StaticResource hideEmptyEnumerationConverter}}"> <ItemsControl ItemsSource="{TemplateBinding Children}"/> </GroupBox> </ControlTemplate> . [ValueConversion(typeof (IEnumerable), typeof (Visibility))] public class HideEmptyEnumerationConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int itemCount = ((IEnumerable) value).Cast<object>().Count(); return itemCount == 0 ? Visibility.Collapsed : Visibility.Visible; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } #endregion } Another, more general question: How do you guys debug bindings? Found this (http://bea.stollnitz.com/blog/?p=52) but still I find it very hard to do. I am glad for any help or suggestion.

    Read the article

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