Search Results

Search found 4490 results on 180 pages for 'binding'.

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

  • 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

  • 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

  • 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

  • C# Late Binding for Parameterized Property

    - by optim
    I'm trying to use late binding to connect to a COM automation API provided by a program called Amibroker, using a C# WinForms project. So far I've been able to connect to everything in the API except one item, which I believe to be a "parameterized property" based on extensive Googling. Here's what the API specification looks like according to the docs (Full version here: http://www.amibroker.com/guide/objects.html): Property Filter(ByVal nType As Integer, ByVal pszCategory As String) As Long [r/w] A javascript snippet to update the value looks like this: AB = new ActiveXObject("Broker.Application"); AA = AB.Analysis; AA.Filter( 0, "market" ) = 0; Using the following C# late-binding code, I can get the value of the property, but I can't for the life of me figure out how to set the value: object[] parameter = new object[2]; parameter[0] = Number; parameter[1] = Type; object filters = _analysis.GetType().InvokeMember("Filter", BindingFlags.GetProperty, null, _analysis, parameter); So far I have tried: using BindingFlags.SetProperty, BindingFlags.SetField casting the returned object to a PropertyInfo object and trying to update the value using it adding extra object containing the value to the parameters object various other things as last-ditch efforts From what I can see, this should be straight-forward, but I'm finding the late binding in C# to be cumbersome at best. The property looks like a method call to me, which is what is throwing me off. How does one assign a value to a method, and what would the prototype for late-binding C# code look like for it? Hopefully that explains it well enough, but feel free to ask if I've left anything unclear. Thanks in advance for any help! Daniel

    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

  • Binding lineargradientbrush color with property

    - by user1629894
    I have a problem with color in gradientstop. I want binding offset color with my property that return color (System.Windows.Media), but not working and return defalt color Transparent. If binding same property with Foreground Label is working. This style is in ResourceDictionary. <Style TargetType="{x:Type TabControl}"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush StartPoint="0 0" EndPoint="0 1"> <LinearGradientBrush.GradientStops> <GradientStop Offset="0.1" Color="Black" /> <GradientStop Offset="1" Color="{Binding Path=MyColor}" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Setter.Value> </Setter> </Style> and it's working: <Style TargetType="{x:Type Label}"> <Setter Property="Foreground" Value="{Binding Path=MyColor, Converter={StaticResource ColorToBrush}}" /> </Style> my property is: public Color MyColor { set { myColor = value; NotifyPropertyChanged("MyColor"); } get { return myColor; } } Thank you everybody for answers

    Read the article

  • WPF binding problem

    - by Lolo
    I've got problem with binding in XAML/WPF. I created Action class witch extends FrameworkElement. Each Action has list of ActionItem. The problem is that the Data/DataContext properties of ActionItem are not set, so they are always null. XAML: <my:Action DataContext="{Binding}"> <my:Action.Items> <my:ActionItem DataContext="{Binding}" Data="{Binding}" /> </my:Action.Items> </my:Action> C#: public class Action : FrameworkElement { public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register("Items", typeof(IList), typeof(Action), new PropertyMetadata(null, null), null); public Action() { this.Items = new ArrayList(); this.DataContextChanged += (s, e) => MessageBox.Show("Action.DataContext"); } public IList Items { get { return (IList)this.GetValue(ItemsProperty); } set { this.SetValue(ItemsProperty, value); } } } public class ActionItem : FrameworkElement { public static readonly DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(object), typeof(ActionItem), new PropertyMetadata( null, null, (d, v) => { if (v != null) MessageBox.Show("ActionItem.Data is not null"); return v; } ), null ); public object Data { get { return this.GetValue(DataProperty); } set { this.SetValue(DataProperty, value); } } public ActionItem() { this.DataContextChanged += (s, e) => MessageBox.Show("ActionItem.DataContext"); } } Any ideas?

    Read the article

  • Binding a single array cell to a WPF control

    - by yomi
    Hi, I have a bool array of size 4 and I want to bind each cell to a different control. This bool array represents 4 statuses (false = failure, true = success). This bool array is a propery with a class: class foo : INotifyPropertyChanged { ... private bool[] _Statuses; public bool[] Statuses { get {return Statuses;} set { Statuses = value; OnPropertyChanged("Statuses"); } } In XAML there are 4 controls, each one bound to one cell of the array: ... Text="{Binding Path=Statuses[0]}" ... ... Text="{Binding Path=Statuses[1]}" ... ... Text="{Binding Path=Statuses[2]}" ... ... Text="{Binding Path=Statuses[3]}" ... The problem is that the notify event is raised only when I change the array itself and isn't raised when I change one value within the array, i.e, next code line raises the event: Statuses = new bool[4]; but next line does not raises the event: Statuses [0] = true; How can I raise the event each time one cell is changed?

    Read the article

  • WCF help, how can I expose a service over http, that calls another service over net.tcp?

    - by Hcabnettek
    Hi All, I have a WCF .svc file hosted in IIS. I want to use basicHTTP binding. This services job is to actually call another service over net.tcp. Everything works fine locally, but when I deployed, I'm getting this error. The provided URI scheme 'http' is invalid; expected 'net.tcp'. Parameter name: via Here is the server config <client> <endpoint address="net.tcp://localhost:9300/InternalInterfaceService" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IInternalInterfaceService" contract="IInternalInterfaceService" name="NetTcpBinding_IInternalInterfaceService"> <identity> <servicePrincipalName value="localhost" /> </identity> </endpoint> </client> <services> <service name="MyExternalService"> <endpoint address="" binding="basicHttpBinding" contract="IMyExternalService" /> </service> </services> And here is the config that svcutil generates <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IMyExternalService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://myserver.somesdomain.com/Services/MyExternalService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyExternalService" contract="IMyInternalService" name="BasicHttpBinding_IMyExternalService" /> </client> </system.serviceModel> What do I need to do to wire this up correctly. I do not want to expose InternalInterfaceService over http. What am I doing incorrectly here? Any tips or suggestions are certainly appreciated. Thanks, ~ck

    Read the article

  • How to set a binding in WPF Toolkit Datagrid's ContextMenu CommandParameter

    - by Boris Lipschitz
    I need to create a ContextMenu where I want to pass a currently selected index of the datagrid to a ViewModel using CommandParameter. The following Xaml code doesn't work. What might be the problem? <dg:DataGrid ItemsSource="{Binding MarketsRows}" <dg:DataGrid.ContextMenu > <ContextMenu > <MenuItem Header="Add Divider" CommandParameter="{Binding Path=SelectedIndex, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dg:DataGrid}}}" Command="{Binding Path= AddDividerCommand}"/> </ContextMenu> </dg:DataGrid.ContextMenu> </dg:DataGrid>

    Read the article

  • WPF binding Ancestor

    - by JerryVienna
    Hi Experts, I have problems with bindings. I want to use a UserControl (Intellibox from codeplex) but I only get error messages in the output window. Basically I have window grid ... stuff ... usercontrol (self written) ... stuff ... usercontrol (IntelliBox) In the Output window I get following stuff: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.UserControl', AncestorLevel='1''. BindingExpression:Path=ShowResults; DataItem=null; target element is 'Popup' (Name='IntelliboxPopup1'); target property is 'IsOpen' (type 'Boolean') The binding in the IntelliBox control is defined as follows: {Binding Path=ShowResults, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}} I guess there is a problem, cause the nesting withing usercontrols - how to I get this error fixed? Thanks!

    Read the article

  • WPF MVVM: TextBox and default Button binding does update too late

    - by Sam
    I've got a simple WPF dialog with these two controls: <TextBox Text="{Binding MyText}"/> <Button Command="{Binding MyCommand}" IsDefault="True"/> Now, when I enter some text in the TextBox and click the button using the mouse, everything works like expected: the TextBox will set MyText and MyCommand is called. But when I enter some text and hit enter to "click" the default button, it does not work. Since on hitting enter the focus does not leave the TextBox, the binding will not be refresh MyText. So when MyCommand is called (which works), MyText will contain old data. How do I fix this in MVVM? In classic code-behind I probably just would call "MyButton.Focus()" in the MyCommand handler, but in MVVM the MyCommand handler does know nothing about the button. So what now`?

    Read the article

  • Binding collection indexes to a WPF DataGrid at runtime

    - by bearda
    After trying to develop our own control to display a table of data we stumbled on the WPF toolkit DataGrid and thought we were saved. A couple hours later I'm scratching my head trying to figure out if it can do what we really want it to do. The DataGrid seems to be based on displaying various properties of a single object, where I think I need something that can display a collection's items, I want to display a table of strings with a variable number of rows and a variable number of columns. Each row represents the state of a number of inputs at a given time. The number of samples may change, and the number of inputs may change at runtime. As a result, I can't create a custom object that represents a row with a property for each input. This makes the DataGrid binding more complicated, since I can't bind to a fixed property for each column. I thought I found a workaround for this by binding to ".[" + channelIndex + ]" but it hasn't worked out quite the way I wanted. Right now I have a collection of a collection of strings that represents the two-dimensional array of strings. I'm using ObservableCollection so string change event notifications work, but I can use any collection type needed. It looked like everything was working great until I realized that every row was showing the same line of data. Binding in C# is not my strong suit, so I'm kind of lost on what's going wrong. Is what I'm trying to do overall even possible with the WPF Toolkit DataGrid? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Microsoft.Windows.Controls; using System.ComponentModel; using System.Collections; using System.Collections.ObjectModel; namespace WRE.NGDAS.UILayer { /// <summary> /// Interaction logic for DataTableControl.xaml /// </summary> public partial class DataTableControl : UserControl { #region Constants private const int lineHeight = 25; #endregion #region Type Definitions private class TableChannelInfo { internal string ChannelName = string.Empty; internal int Column = 0; public override string ToString() { return ChannelName; } } internal class NotifyString : INotifyPropertyChanged { private string text = String.Empty; public event PropertyChangedEventHandler PropertyChanged; public string Text { get { return text; } set { text = value; NotifyPropertyChanged( "Text" ); } } public NotifyString(string newText) { text = newText; } protected void NotifyPropertyChanged( string propertyChanged ) { if ( PropertyChanged != null ) { PropertyChanged(this, new PropertyChangedEventArgs(propertyChanged)); } } } #endregion #region Private Data Members string[] channels = null; int numberFixed = 0; int numberOfRows = 0; ObservableCollection<ObservableCollection<NotifyString>> tableText = null; #endregion public DataTableControl( List<string> channelNames, List<string> nameToolTips, int numberFixedColumns, int numberRows ) { InitializeComponent(); numberFixed = numberFixedColumns; numberOfRows = numberRows; tableText = new ObservableCollection<ObservableCollection<NotifyString>>(); dataGrid.ItemsSource = tableText; channels = new string[channelNames.Count]; for (int channelIndex = 0; channelIndex < channelNames.Count; channelIndex++) { channels[channelIndex] = channelNames[channelIndex]; tableText.Add(new ObservableCollection<NotifyString>()); for (int i = 0; i < numberOfRows; i++) { tableText[channelIndex].Add( new NotifyString(String.Empty) ); } Binding textBinding = new Binding( ".[" + channelIndex + "]" ); textBinding.Mode = BindingMode.OneWay; textBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; textBinding.Source = tableText[channelIndex]; DataGridTextColumn newColumn = new DataGridTextColumn(); newColumn.Header = channelNames[channelIndex]; newColumn.DisplayIndex = channelIndex; newColumn.Binding = textBinding; if ( channelIndex < numberFixed ) { newColumn.CanUserReorder = false; } dataGrid.Columns.Add(newColumn); } //Height = lineHeight + numberOfRows * lineHeight; } internal void UpdateChannelRow( int rowNumber, List<string> channelValues, DisplayColors color ) { if ( rowNumber < numberOfRows ) { for (int column = 0; column < channelValues.Count; column++) { if ( column < channels.GetLength(0) ) { tableText[column][rowNumber].Text = channelValues[column]; } } } } } }

    Read the article

  • Silverlight - Binding ImageSource to Rectangle Fill

    - by Matt.M
    Blend 4 is telling me this is invalid markup and its not telling me why: <ImageBrush Stretch="Fill" ImageSource="{Binding Avatar, Mode=OneWay}"/> I'm pulling data from a Twitter feed, saving to an ImageSource, and then binding it to an ImageBrush(as seen below) to be used as the Fill for a Rectangle. Here is more context: <Rectangle x:Name="Avatar" RadiusY="9" RadiusX="9" Width="45" Height="45" VerticalAlignment="Center" HorizontalAlignment="Center" > <Rectangle.Fill> <ImageBrush Stretch="Fill" ImageSource="{Binding Avatar, Mode=OneWay}"/> </Rectangle.Fill> </Rectangle> I'm using this inside of a Silverlight UserControl, which is used inside of a Silverlight Application. Any Ideas on what the problem could be?

    Read the article

  • WCF Message Debugging on Custom Binding

    - by Programming Hero
    I've created a custom binding in WCF for a custom MessageEncoder to allow messages to be written as XML using a wider range of encodings than WCF supports out of the box. The encoder appears to be working and I am able to send and receive messages, but I want to verify that the XML message being written is exactly as required by the service I am trying to consume. I've turned on message logging for WCF using the diagnostic trace listeners to output the messages sent and received over the wire to a log file. Unfortunately, for calls using my encoder, the message is displayed as ... stream ... EDIT: I don't think it's anything to do with my custom encoding. I have experimented with my custom binding a little, switching to using the built-in text encoding and http transport. I still don't get a message body logged in the message trace. Is there anything that needs to be specified within a custom binding to enable message logging?

    Read the article

  • Silverlight Binding to TranslateX

    - by Peanut
    I have a simple winphone7 application, but I think this would apply to any silverlight. Basically I have an ellipse and I would like to move it with the translate X and Y properties. Here is my attempt: <Ellipse Fill="#FFF4F4F5" Margin="0,0,-3,-3" Stroke="Black" RenderTransformOrigin="0.5,0.5" > <Ellipse.RenderTransform> <CompositeTransform TranslateY="{Binding Y}" TranslateX="{Binding X}"/> </Ellipse.RenderTransform> </Ellipse> I am pretty sure the Binding is set correctly; The problem is it gives me this error when I run the application: 2260 An error has occurred. [Line: 4 Position: 33] which is a XAML error. The error goes away when I comment out the composittransform line. Can anyone point me in a right direction? If you need more code let me know, i'll post more up. Thanks

    Read the article

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