databinding

Proper MXML Class Factory

I would really like to be able to write something like the following: <magical:ClassFactory id="factory"> <some:UIComponentOrWhatever with_event="handlers(event)" event_snippets="like.so()" code_values="{ foo + ' ' + bar }" bound_values="{bindabl...

WPF DataGrid with XmlDataProvider simple example

After a few hours trying to reach some working sample i decided to try my luck here. I am a newbie to WPF, but things should get easier with time ... I am trying to have a DataGrid showing an XML file i have. That's it. I have in my application cars.xml <cars> <car type="Ford" size="4" /> <car type="Mercedes" size="2" /> ...

WPF DataBinding: Bind to a property that references two other properties

Basically, how do I bind (one-way) to a textbox named txtFullName. Initially, any text in the text box gets cleared/blanked out since ToString returns "". But, when I make changes to FirstName or LastName it does not update the binding against FullName. Any way to do this? Also, is there any way to bind to a method (not just a field)? T...

TabControl Styling in WPF

I have a collection of objects which contains a child collection. I can get the parent collection to show properly on the tabs. But I cannot get the child collection to show in the content pane. here is my XAML: <d:DataContext> <Binding Source="{StaticResource SearchResultsViewModel}" /> </d:DataContext> <TabControl TabSt...

How to add data validation to Silverlight 4 master-detail MVVM bound form?

Hi all, I have a Silverlight 4 application using a master/detail type UI arrangement. There is a Silverlight 4 datagrid control bound to an ObservableCollection<T> property of a custom ViewModel class I have created. Below the grid is a detail section that shows the individual detail information for each row of the grid. Each of the ...

WPF DataBinding Validation being ignored

I (believe) I'm wiring up DataBinding Validation in a textbook manner, but it just isn't working - at all. In the debugger, the Validate(object value, CultureInfo cultureInfo) method is never called. What gives? Also, for bonus points, any pointers on debugging WPF would be awesome. I'm posting my XAML and the class in question <Use...

WPF binding of string property and Button.Content

I want to bind string property with Button.Content. But why it didn't work? The data class: namespace test4 { public class Test : INotifyPropertyChanged { string _Text = "Begin"; public string Text { get{return _Text;} protected set { _Text = value; } } publi...

save bindings to XAML

According to Microsoft, http://msdn.microsoft.com/en-us/library/ms754193.aspx#Extension_References_are_Dereferenced bindings are not serialized to XAML when using XamlWriter. Has anyone implemented a way to save these bindings to XAML? ...

what converts aspx files into c#

which process or class is responsible for converting aspx files and data-binding expressions into c# ? for example <%# Eval("XXXXX") %> is transformed into: public void @__DataBind__control118(object sender, System.EventArgs e) { System.Web.UI.WebControls.RepeaterItem Container; System.Web.UI.DataBoundLitera...

WPF DataBinding: Nullable Int still gets a validation error?

I have a textbox databound to a nullable int through code. If I erase the data from the textbox it gives me a validation error (red border around it). Here is my binding code: ZipBinding = new Binding("Zip"); ZipBinding.Source = Address; zipTextBox.SetBinding(TextBox.TextProperty, ZipBinding); public Int32? Zip { get { ... } set { ......

ComboBox.SelectedValue is messed up after binding to a List.

Hi guys, I am losing my senses here... I have ComboBox on the form with one property changed, Sorted = true. This property is messing up with SelectedValue and I would like to know why. take a look at the code(you can paste it to the new WinForms project and it will work after adding a combobox): private void Form1_Load(object se...

Adding logic to a data bound property to initiate animations in WPF

I feel like this is a very simple question, but I can't really find any examples on the internet of anyone who wants to do something like this. What I have right now is a half circle gauge control that I made in WPF. I have a RotateTransform that has data bound to its angle so as the data comes in it shows the angle visually. The problem...

Databinding/PropertyChanged Notification on object reassignement (Silverlight 4/C#)

I have a textblock bound to an object. The 2-way binding works well and as expected. In the code-behind: txtNumberOfPlayers.DataContext = tournament.ChipSet; In the .xaml: <toolkit:NumericUpDown x:Name="txtNumberOfPlayers" Value="{Binding NumberOfPlayers, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" /> ...

Binding RectangleGeometry.Rect doesn't show the rectangle

I'm having an issue trying to bind to a RectangleGeometry's Rect property. The basic idea here is that I'm attempting to bind a clip mask to control the visualized height of a pseudo-chart object. Here's the XAML: <Path x:Name="_value" Fill="{DynamicResource PositiveColorBrush}" Data="F1 M10,55 C10,57.75 7.75,60 5,60 2.25,60 0,57.75...

ListBox ItemTemplate is fickle with CLR and UserControl data

I wrote a simple UpDown UserControl for my application. I am rendering it in a ListBox so that as UpDown controls get added, they stack up horizontally. My UserControl has one DependencyProperty that corresponds to the number inside of the UpDown control, called NumberProperty. I add multiple UpDown controls to the ListBox via databin...

test Wpf Control performance

Specifically for data binding and templates, is there a good way to test the performance of my controls in these respects. I would like to know how much time applying the template and initializing the data binding takes. I am using both Wpf Performance Suite and ANTS Profiler but neither seems to provide information on these aspects. ...

How to get total row count and why is the GridView's DataSource property null in the DataBound event handler?

I wanted to get the total row count in a GridView's databound event handler, so I tried the following: protected void grid_DataBound(object sender, EventArgs e) { GridView grid = (GridView)sender; DataSet data = grid.DataSource as DataSet; if (data == null) return; int totalRows = data.Tables[0...

How do I convert a Color to a Brush in XAML?

I want to convert a System.Windows.Media.Color value to a System.Windows.Media.Brush. The color value is databound to a Rectangle object's Fill property. The Fill property takes a Brush object, so I need an IValueConverter object to perform the conversion. Is there a built-in converter in WPF or do I need to create my own? How do I go a...

Silverlight DataBinding, avoid BindingExpression Path error on missing properties, hide controls instead

Hi Stackoverflowers! imagine the following simple Models (example for simplicity reasons; in fact, we have MVVM here but it doesn't matter): public class User { public string Username { get; set; } } public class StackOverflowUser : User { public int Reputation { get; set; } } Now we have a Silverlight UserControl which contains...

Possible databinding bug on progress bar when datacontext changes (Silverlight 4)

I have a progress bar bound to 2 integer values - One is the total seconds and the other is the seconds left (which counts down on a timer: always <= Total seconds). I have the LayoutRoot datacontext set to my top level object (of which BlindSet is a property -see code). When I run the project the progress bar updates perfectly. It cou...