Search Results

Search found 5504 results on 221 pages for 'late binding'.

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

  • Binding not working correctly in silverlight

    - by Harsh Maurya
    I am using a DataGrid in my silverlight project which contains a custom checkbox column. I have binded its command property with a property of my ViewModel class. Now, the problem is that I want to send the "selected item" of DataGrid through the command paramter for which I have written the following code : <sdk:DataGrid AutoGenerateColumns="False" Margin="10,0,10,0" Name="dataGridOrders" ItemsSource="{Binding OrderList}" Height="190"> <sdk:DataGrid.Columns> <sdk:DataGridTemplateColumn Header="Select"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox> <is:Interaction.Triggers> <is:EventTrigger EventName="Checked"> <is:InvokeCommandAction Command="{Binding Source={StaticResource ExecutionTraderHomePageVM},Path=OrderSelectedCommand,Mode=TwoWay}" CommandParameter="{Binding ElementName=dataGridOrders,Path=SelectedItem}" /> </is:EventTrigger> <is:EventTrigger EventName="Unchecked"> <is:InvokeCommandAction Command="{Binding Source={StaticResource ExecutionTraderHomePageVM},Path=OrderSelectedCommand,Mode=TwoWay}" CommandParameter="{Binding ElementName=dataGridOrders,Path=SelectedItem}" /> </is:EventTrigger> </is:Interaction.Triggers> </CheckBox> But I am always getting null in the parameter of my command's execute method. I have tried with other properties of DataGrid such as Width, ActualHeight e.t.c. but of no use. What am I missing here ?

    Read the article

  • Windows 8 Data Binding Bug - OnPropertyChanged Updates Wrong Object

    - by Andrew
    I'm experiencing some really weird behavior with data binding in Windows 8. I have a combobox set up like this: <ComboBox VerticalAlignment="Center" Margin="0,18,0,0" HorizontalAlignment="Right" Height="Auto" Width="138" Background="{StaticResource DarkBackgroundBrush}" BorderThickness="0" ItemsSource="{Binding CurrentForum.SortValues}" SelectedItem="{Binding CurrentForum.CurrentSort, Mode=TwoWay}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock HorizontalAlignment="Right" Text="{Binding Converter={StaticResource SortValueConverter}}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> Inside of a page with the DataContext set to a statically located ViewModel. When I change that ViewModel's CurrentForm attribute, who's property is implemented like this... public FormViewModel CurrentForm { get { return _currentForm; } set { _currentForm = value; if (!_currentForm.IsLoaded) { _currentSubreddit.Refresh.Execute(null); } RaisePropertyChanged("CurrentForm"); } } ... something really strange happens. The previous FormViewModel's CurrentSort property is changed to the new FormViewModel's current sort property. This happens as the RaisePropertyChanged event is called, through a managed-to-native transition, with native code invoking the setter of CurrentSort of the previous FormViewModel. Does that sound like a bug in Win8's data binding? Am I doing something wrong?

    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

  • Windows authetication with Silverlight custom binding.

    - by sfx
    Hello, I am trying to set up security within a web.config file for a WCF service hosted in IIS but keep getting the error message: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. I have read Nicholas Allen’s blog (link text) and it appears that this is the route that I need to take. However, I am using “binaryMessageEncoding” in a customBinding for my Silverlight service, and as such, I’m not sure how to apply this type of security to such an element. This is how my custom binding looks in config at present: <customBinding> <binding name="silverlightBinaryBinding"> <binaryMessageEncoding /> <httpTransport /> </binding> </customBinding> Has anyone had any experience getting Windows authentication to work with a custom binding using binaryMessageEncoding? Cheers, sfx

    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

  • Binding between Usercontrol with listbox and parent control (MVVM)

    - by walkor
    I have a UserControl which contains a listbox and few buttons. <UserControl x:Class="ItemControls.ListBoxControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> <Grid> <ListBox:ExtendedListBox SelectionMode="Single" ItemsSource="{Binding LBItems}" Height="184"> <ListBox.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <Button Command="RemoveCommand"/> </Grid> </UserControl> And the code behind: public static readonly DependencyProperty RemoveCommandProperty = DependencyProperty.Register("RemoveCommand", typeof(ICommand), typeof(ListBoxControl), null); public ICommand RemoveCommand { get { return (ICommand)GetValue(RemoveCommandProperty); } set { SetValue(RemoveCommandProperty, value); } } public static readonly DependencyProperty LBItemsProperty = DependencyProperty.Register("LBItems", typeof(IEnumerable), typeof(ListBoxControl), null); public IEnumerable LBItems { get { return (IEnumerable)GetValue(LBItemsProperty); } set { SetValue(LBItemsProperty, value); } } I'm using this control in the view like this: <ItemControls:ListBoxControl Height="240" Width="350" LBItems="{Binding Items, Converter={StaticResource ItemsConverter}, Mode=TwoWay}" RemoveCommand="{Binding RemoveCommand}"/> The command works fine, though the listbox binding doesn't. My question is - WHY?

    Read the article

  • WPF ComboBox Binding + Selected Index for object.

    - by abmv
    I have a case of WPF binding I want to solve: The issue is that I have a user detail screen and it has a employee combo box that gets filled with employees. cbxEmployee.ItemsSource = DataAccess.GetCollectionView("Employee", "[Active] = True", viewModel.Context); cbxEmployee.DisplayMemberPath = "FullName"; cbxEmployee.SelectedValuePath = "ID"; The binding in user detail screen xaml is for the user object, I just need the employee id to store in the int property.So no problems when the user selects an employee. <ComboBox x:Name="cbxEmployee" SelectedItem="{Binding Path=Employee,ValidatesOnExceptions=True}" SelectedValue="{Binding Path=AssociatedEmployeeId}" Style="{DynamicResource InputBaseStyle}"/> Now the issue is that when an existing object is edited I need the combo box to get the correct employee to be shown,i.e the index should be set at the correct employee for the AssociatedEmployeeId of the user object. Well how the heck should I do it ? Any advice?

    Read the article

  • jquery "this" binding issue on event handler

    - by clyfe
    In jquery an event hadler's binding is the event generating DOM element (this points to the dom element). In prototype to change the binding of an event handler one can use the bindAsEventListener function; How can I access both the instance and the DOM element from a event handler? Similar to http://stackoverflow.com/questions/117361/how-can-i-bind-an-event-handler-to-an-instance-in-jquery function Car(){ this.km = 0; $("#sprint").click(this.drive); //setup event handler } // event handler // in it I need to access both the clicked element // and the binding object (instance of car) Car.prototype.drive = function(){ this.km += 10; // i'd like to access the binding (but jq changes it) this.css({ left: this.km }); // also the element // NOTE that is inside this function I want to access them not elsewhere } var car = new Car();

    Read the article

  • Binding with custom text in WPF

    - by nihi_l_ist
    Can i write something like this in WPF(i know that this piece of code is wrong, but need to know if there is kind of this construct): <TextBlock Height="50" Text="Test: {Binding Path=MODULE_GUID}" /> Or always to add some text to binding value i must do something like this: <StackPanel Orientation="Horizontal"> <TextBlock Height="50" Text="Test: " /> <TextBlock Height="50" Text="{Binding Path=MODULE_GUID}" /> </StackPanel>

    Read the article

  • DataGrid : Binding with two different classes with lists ? WPF C#

    - by MyRestlessDream
    It is my first question on StackOverflow so I hope I am doing nothing wrong ! Sorry if it is the case ! I need some help because I can not find the solution of my problem. Of course I have searched everywhere on the web but I can not find it (can not post the links that I am using because of my low reputation :( ). Moreover, I am new in C# and WPF (and self-learning). I used to work in C++/Qt so I do not know how everything works in WPF. And sorry for my English, I am French. My problem My basic classes are that an Employee can use a computer. The id of the computer and the date of use are stored into the class Connection. I would like to display the list information in a DataGrid and in RowDetailsTemplate like here : http://i.stack.imgur.com/Bvn1z.png So it will do a binding to the Employee class but also to the Connection class with only the last value of the property (here the last value of the list "Computer ID" and the last value of the list "Connection Date" on this last computer). So it is a loop in the different lists. How can I do it ? Is it too much to do ? :( I succeed to get the Employee informations but I do not know how to bind the list of computer. When I am trying, it shows me "(Collection)" so it does not go inside the list :( Summary of Questions How to display/bind a value from a list AND from a different class in a DataGrid ? How to display all the values of a list into the RowDetailsTemplate ? Under Windows 7 and Visual Studio 2010 Pro version. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EDIT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Solution I have used the solution of Stefan Denchev. Here the modification of my class : http://i.stack.imgur.com/Ijx5i.png And the code used: <DataGrid ItemsSource="{Binding}" Name="table"> <DataGrid.Columns> <DataGridTextColumn Header="First Name" Binding="{Binding FirstName}"/> <DataGridTextColumn Header="Last Name" Binding="{Binding LastName}"/> <DataGridTextColumn Header="Gender" Binding="{Binding Gender}"/> <DataGridTextColumn Header="Last computer used" Binding="{Binding LastComputerID}"/> <DataGridTextColumn Header="Last connection date" Binding="{Binding LastDate}"/> </DataGrid.Columns> <DataGrid.RowDetailsTemplate> <DataTemplate> <DataGrid ItemsSource="{Binding ListOfConnection}"> <DataGrid.Columns> <DataGridTextColumn Header="Computer ID" Binding="{Binding ComputerID}"/> <DataGridTemplateColumn> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ListView ItemsSource="{Binding ListOfDate}"/> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid> </DataTemplate> </DataGrid.RowDetailsTemplate> </DataGrid> With in code behind : List<Employee> allEmployees = WorkflowMgr.Instance.AllEmployees; table.DataContext = allEmployees; And it works ! I have tryed to improve my fake example :) Hope it will help to another developer !

    Read the article

  • Introduction to Lean Software Development and Kanban Systems – Defer Commitment and Decide As Late A

    - by Ben Griswold
    In this post, we’ll continue the series by concentrating on Principle #4: Defer Commitment and Decide As Late As Possible.   In the next part of the series, we’ll dive into Principle #5: Deliver As Fast As Possible. And I am going to be a little obnoxious about listing my Lean and Kanban references with every series post.  The references are great and they deserve this sort of attention.  

    Read the article

  • Interpreted vs. Compiled vs. Late-Binding

    - by zubin71
    Python is compiled into an intermediate bytecode(pyc) and then executed. So, there is a compilation followed by interpretation. However, long-time Python users say that Python is a "late-binding" language and that it should`nt be referred to as an interpreted language. How would Python be different from another interpreted language? Could you tell me what "late-binding" means, in the Python context? Java is another language which first has source code compiled into bytecode and then interpreted into bytecode. Is Java an interpreted/compiled language? How is it different from Python in terms of compilation/execution? Java is said to not have, "late-binding". Does this have anything to do with Java programs being slighly faster than Python? Itd be great if you could also give me links to places where people have already discussed this; id love to read more on this. Thank you.

    Read the article

  • TwoWay Binding With ItemsControl

    - by Andrew
    I'm trying to write a user control that has an ItemsControl, the ItemsTemplate of which contains a TextBox that will allow for TwoWay binding. However, I must be making a mistake somewhere in my code, because the binding only appears to work as if Mode=OneWay. This is a pretty simplified excerpt from my project, but it still contains the problem: <UserControl x:Class="ItemsControlTest.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300"> <Grid> <StackPanel> <ItemsControl ItemsSource="{Binding Path=.}" x:Name="myItemsControl"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBox Text="{Binding Mode=TwoWay, UpdateSourceTrigger=LostFocus, Path=.}" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> <Button Click="Button_Click" Content="Click Here To Change Focus From ItemsControl" /> </StackPanel> </Grid> </UserControl> Here's the code behind for the above control: using System; using System.Windows; using System.Windows.Controls; using System.Collections.ObjectModel; namespace ItemsControlTest { /// <summary> /// Interaction logic for UserControl1.xaml /// </summary> public partial class UserControl1 : UserControl { public ObservableCollection<string> MyCollection { get { return (ObservableCollection<string>)GetValue(MyCollectionProperty); } set { SetValue(MyCollectionProperty, value); } } // Using a DependencyProperty as the backing store for MyCollection. This enables animation, styling, binding, etc... public static readonly DependencyProperty MyCollectionProperty = DependencyProperty.Register("MyCollection", typeof(ObservableCollection<string>), typeof(UserControl1), new UIPropertyMetadata(new ObservableCollection<string>())); public UserControl1() { for (int i = 0; i < 6; i++) MyCollection.Add("String " + i.ToString()); InitializeComponent(); myItemsControl.DataContext = this.MyCollection; } private void Button_Click(object sender, RoutedEventArgs e) { // Insert a string after the third element of MyCollection MyCollection.Insert(3, "Inserted Item"); // Display contents of MyCollection in a MessageBox string str = ""; foreach (string s in MyCollection) str += s + Environment.NewLine; MessageBox.Show(str); } } } And finally, here's the xaml for the main window: <Window x:Class="ItemsControlTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:src="clr-namespace:ItemsControlTest" Title="Window1" Height="300" Width="300"> <Grid> <src:UserControl1 /> </Grid> </Window> Well, that's everything. I'm not sure why editing the TextBox.Text properties in the window does not seem to update the source property for the binding in the code behind, namely MyCollection. Clicking on the button pretty much causes the problem to stare me in the face;) Please help me understand where I'm going wrong. Thanx! Andrew

    Read the article

  • Macbook Pro late 2011 screen brightness issue

    - by buchzumlesen
    The keys to set the screen brightness work properly but everytime I reboot, the screen brightness is reverted to 100%, which is very annoying. I've already tried to add the following lines to /etc/rc.local but with no success (only the keyboard backlight stays off): #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. echo '1' > /sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/brightness echo '6' > /sys/class/backlight/acpi_video0/brightness rfkill block bluetooth exit 0` This worked for me when I was using Ubuntu 12.04 and also did after the upgrade to 12.10 but then after rebooting the screen brightness always reverted to 100%. Would be nice if anyone knows how to fix this. My device: Macbook Pro 13" Late 2011 Thanks in advance!

    Read the article

  • Binding WPF DataGrid to DataTable using TemplateColumns

    - by Chris J
    I have tried everything and got nowhere so I'm hoping someone can give me the aha moment. I simply cannot get the binding to pull the data in the datagrid successfully. I have a DataTable that contains multiple columns with of MyDataType} public class MyData { string nameData {get;set;} boolean showData {get;set;} } MyDataType has 2 properties (A string, a boolean) I have created a test DataTable DataTable GetDummyData() { DataTable dt = new DataTable("Foo"); dt.Columns.Add(new DataColumn("AnotherColumn", typeof(MyData))); dt.Rows.Add(new MyData("Row1C1", true)); dt.Rows.Add(new MyData("Row2C1", false)); dt.AcceptChanges(); return dt; } I have a WPF DataGrid which I want to show my DataTable. But all I want to do is to change how each cell is rendered to show [TextBlock][Button] per cell with values bound to the MyData object and this is where I'm having a tonne of trouble. My XAML looks like this <Window.Resources><ResourceDictionary><DataTemplate x:Key="MyDataTemplate" DataType="MyData"> <StackPanel Orientation="Horizontal" > <Button Background="Green" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0" Content="{Binding Path=nameData}"></Button> <TextBlock Background="Green" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Text="{Binding Path=nameData}"></TextBlock> </StackPanel> </DataTemplate></ResourceDictionary></Window.Resources> <Grid> <dg:DataGrid Grid.Row="1" AutoGenerateColumns="True" x:Name="dataGrid1" SelectionMode="Single" CanUserAddRows="False" CanUserSortColumns="true" CanUserDeleteRows="False" AlternatingRowBackground="AliceBlue" AutoGeneratingColumn="dataGrid1_AutoGeneratingColumn" ItemsSource="{Binding}" /> now all I do once loaded is to attempt to bind the DataTable to the WPF DataGrid dt = GetDummyData(); dataGrid1.ItemsSource = dt.DefaultView; The TextBlock and Button show up, but they don't bind, which leaves them blank. Could anyone let me know if they have any idea how to fix this. This should be simple, thats what Microsoft leads us to believe. I have set the Column.CellTemplate during the AutoGenerating event and still get no binding. Please help!!!

    Read the article

  • Problem Binding a ObservableCollection to a ListBox in WPF/MVVM

    - by alexqs
    I'm working in some code , using wpf and starting to use mvvm. So far i have no problem, when i have one element and I have to show the values of it in the screen (binding of the specific name of the property). But now, i have to work with a property list , not knowing the names of it. So I created a class, named GClass, that only have two propierties, name and value. I created the ObservableCollection, and fill for now with direct values, and asign the view (lstview) datacontext with the object i have created. But I cant see any result, it always shows a blank listbox. Can someone tell me if see why is happening ? Code of c# VDt = new ObservableCollection<GClass>(); var vhDt = message.SelectSingleElement(typeof (Vh)) as Vehiculo; if(vhDt != null) { VDt.Add(new GClass() {Name = "Numero: ", Value = ""}); VDt.Add(new GClass() {Name = "Marca: ", Value = ""}); VDt.Add(new GClass() {Name = "Conductor: ", Value = ""}); lstview.DataContext = this; _regionManager.RegisterViewWithRegionInIndex(RegionNames.MainRegion, lstview, 0); Code of the view <ListBox Margin="5,5,5,25" ItemsSource="{Binding VDt}"> <ListBox.Template> <ControlTemplate> <ListViewItem Content="{Binding Name}"></ListViewItem> <ListViewItem Content="{Binding Value}"></ListViewItem> </ControlTemplate> </ListBox.Template> </ListBox> I have research here, but i cant see, what I'm doing wrong. I will apreciate if someone help me.

    Read the article

  • Trouble binding WPF Menu to ItemsSource

    - by chaiguy
    I would like to avoid having to build a menu manually in XAML or code, by binding to a list of ICommand-derived objects. However, I'm experiencing a bit of a problem where the resulting menu has two levels of menu-items (i.e. each MenuItem is contained in a MenuItem): My guess is that this is happening because WPF is automatically generating a MenuItem for my binding, but the "viewer" I'm using actually already is a MenuItem (it's derived from MenuItem): <ContextMenu x:Name="selectionContextMenu" ItemsSource="{Binding Source={x:Static OrangeNote:Note.MultiCommands}}" ItemContainerStyleSelector="{StaticResource separatorStyleSelector}"> <ContextMenu.ItemTemplate> <DataTemplate> <Viewers:NoteCommandMenuItemViewer CommandParameter="{Binding Source={x:Static OrangeNote:App.Screen}, Path=SelectedNotes}" /> </DataTemplate> </ContextMenu.ItemTemplate> </ContextMenu> (The ItemContainerStyleSelector is from http://bea.stollnitz.com/blog/?p=23, which allows me to have Separator elements inside my bound source.) So, the menu is bound to a collection of ICommands, and each item's CommandParameter is set to the same global target (which happens to be a collection, but that's not important). My question is, is there any way I can bind this such that WPF doesn't automatically wrap each item in a MenuItem?

    Read the article

  • WinForms data binding with a Save button?

    - by Mat
    How is data binding in C# WinForms supposed to work when you have a Save button? I don't want the data updated until I press Save! I have two forms (list and detail) backed by a BindingList<T> collection and my custom object from that collection, respectively. I can bind each form to the list or object appropriately. However, any changes made in the detail form are immediately reflected in the list form - I don't want to save the changes and update the details shown in the list until the Save button is pressed. Is data binding designed to support this? Is there a common pattern for doing so? Whichever way I look at it, binding doesn't seem to be able to support this scenario. I've considered the following: Pass a clone of the object to the detail form, but then I have to reconcile the changes on Save - changes may have been made to the copy in the list in the meantime. Implementing IEditableObject and calling EndEdit on save almost works as I can prevent the list being notified of the changes made until Save is pressed, but if something else causes a refresh the list is updated with the interim data. I'm currently left with dispensing with data binding in my detail view, and doing it all manually. Which is rather annoying.

    Read the article

  • Confusion about WPF binding...

    - by Vladislav
    I am trying to bind a 2D array of buttons arranged in stackpanels to a 2D ObservableCollection... Yet, I'm afraid I don't understand something very elementary about binding. My XAML: <Window.Resources> <DataTemplate x:Key="ItemsAsButtons"> <Button Content="{Binding}" Height="100" Width="100"/> </DataTemplate> <DataTemplate x:Key="PanelOfPanels"> <ItemsControl ItemsSource="{Binding Path=DayNumbers}" ItemTemplate=" {DynamicResource ItemsAsButtons}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </DataTemplate> </Window.Resources> ... <ItemsControl x:Name="DaysPanel" Grid.ColumnSpan="7" Grid.Row="2" ItemTemplate="{DynamicResource PanelOfPanels}"/> My C# code: The backend: /// <summary> /// Window BE for Calendar.xaml /// </summary> public partial class Calendar : Window { private CalendarViewModel _vm; public Calendar() { InitializeComponent(); _vm = new CalendarViewModel(); this.DataContext = _vm; } } The ViewModel: class CalendarViewModel { CalendarMonth _displayedMonth; EventCalendar _calendar; public CalendarViewModel() { _displayedMonth = new CalendarMonth(); } public ObservableCollection<ObservableCollection<int>> DayNumbers { get { return _displayedMonth.DayNumbers; } } } I'm trying to populate the buttons with values from CalendarViewModel.DayNumbers - yet the buttons do not appear. I'm clearly doing something wrong with my binding.

    Read the article

  • a selective dual command binding converter in WPF?

    - by Jippers
    I'll start off and say I am not using the MVVM pattern for my WPF app. Please forgive me. Right now I have a data template with two buttons, each binds to a different command on the CLR object this data template represents. Both use the same command parameter. Here's an example of the buttons. <Button x:Name="Button1" Command="{Binding Path=Command1}" CommandParameter="{Binding Path=Text, ElementName=TextBox1}" /> <Button x:Name="Button2" Command="{Binding Path=Command2}" CommandParameter="{Binding Path=Text, ElementName=TextBox1}" /> I would like to refactor this into a single button that can perform either command based on a user setting like a boolean in Settings.settings. I don't have access to refactoring the CLR object itself. Also this is a Data Template there isn't codebehind for me to work with. My take is that a converter would be the best bet, but I don't know how I would put that together. The converter would need to take in the CommandParameter, as well as the DataContext so it knows which object to execute the Commands on. Can someone lend me a hand with this? Thanks in advance.

    Read the article

  • Using data binding on value which is a FrameworkElement

    - by JaredPar
    One of my data sources produces a collection of values which are typed to the following interface public interface IData { string Name { get; } FrameworkElement VisualElement { get; } } I'd like to use data binding in WPF to display a collection of IData instances in a TabControl where the Name value becomes the header of the tab and the VisualElement value is displayed as the content of the corresponding tab. Binding the header is straight forward. I'm stuck though on how to define a template which allows me to display the VisualElement value. I've tried a number of solutions with little success. My best attempt is as follows. <TabControl ItemsSource="{Binding}"> <TabControl.ItemTemplate> <DataTemplate> <Label Content="{Binding Name}"/> </DataTemplate> </TabControl.ItemTemplate> <TabControl.ContentTemplate> <DataTemplate> How do I display VisualElement here? </DataTemplate> </TabControl.ContentTemplate> </TabControl> I'm still very new to WPF so I could be missing the obvious here.

    Read the article

  • How to do binding programmically?

    - by user175908
    Hello, Could anyone identify the problem in this code? (I'm kinda newbie in WPF bindings.) This code executes after chart is loaded when I click a button: I get this error: Update: I dont get that error anymore. Thanks to Tomas. Now no error occur but chart looks completely blank (no columns) Update: Code now looks like this: // create a very simple DataSet var dataSet = new DataSet("MyDataSet"); var table = dataSet.Tables.Add("MyTable"); table.Columns.Add("Name"); table.Columns.Add("Price"); table.Rows.Add("Brick", 1.5d); table.Rows.Add("Soap", 4.99d); table.Rows.Add("Comic Book", 0.99d); // chart series var series = new ColumnSeries() { IndependentValueBinding = new Binding("[Name]"), // How to deal with DependentValueBinding = new Binding("[Price]"), // these two? ItemsSource = dataSet.Tables[0].DefaultView // or maybe I do mistake here? }; // ---------- set additional binding as adviced ------------------ series.SetBinding(ColumnSeries.ItemsSourceProperty, new Binding()); // chart stuff MyChart.Series.Add(series); MyChart.Title = "Names 'n Prices"; // some code to remove legend var style = new Style(typeof(Control)); style.Setters.Add(new Setter(LegendItem.TemplateProperty, null)); MyChart.LegendStyle = style; XAML: <Window x:Class="BindingzTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="606" Width="988" xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"> <Grid Name="LayoutRoot"> <charting:Chart Name="MyChart" Margin="0,0,573,0" Height="289" VerticalAlignment="Top" /> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="272,361,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="chart1_Loaded" /> </Grid> Thanks for help in advance once more.

    Read the article

  • WPF Binding to variable / DependencyProperty

    - by Peter
    I'm playing around with WPF Binding and variables. Apparently one can only bind DependencyProperties. I have come up with the following, which works perfectly fine: The code-behind file: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } public string Test { get { return (string)this.GetValue(TestProperty); } set { this.SetValue(TestProperty, value); } //set { this.SetValue(TestProperty, "BBB"); } } public static readonly DependencyProperty TestProperty = DependencyProperty.Register( "Test", typeof(string), typeof(MainWindow), new PropertyMetadata("CCC")); private void button1_Click(object sender, RoutedEventArgs e) { MessageBox.Show(Test); Test = "AAA"; MessageBox.Show(Test); } } XAML: <Window x:Class="WpfApplication3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase" Title="MainWindow" Height="350" Width="525" DataContext="{Binding RelativeSource={RelativeSource Self}}"> <Grid> <TextBox Height="31" HorizontalAlignment="Left" Margin="84,86,0,0" Name="textBox1" VerticalAlignment="Top" Width="152" Text="{Binding Test, Mode=TwoWay, diag:PresentationTraceSources.TraceLevel=High}"/> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="320,85,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> <TextBox Height="31" HorizontalAlignment="Left" Margin="84,138,0,0" Name="textBox2" Text="{Binding Test, Mode=TwoWay}" VerticalAlignment="Top" Width="152" /> </Grid> The two TextBoxes update one an other. And the Button sets them to "AAA". But now I replaced the Setter function with the one that is commented out (simulating some manipulation of the given value). I would expect that whenever the property value is changed it will be reset to "BBB". It does so when you press the button, that is when you set the property in code. But it does for some reason not affect the WPF Bindings, that is you can change the TextBox contents and thus the property, but apparently the Setter is never called. I wonder why that is so, and how one would go about to achive the expected behaviour.

    Read the article

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