xaml

Setting default value of DateTimePicker

Currently my DateTimePickers are blank, I would like them to have a default setting i.e Today.AddYears(20); & Today.AddDays(5); What I have done at the moment is 'DateTimePicker.Text = DateTime.Today.AddYears(-100).ToString();' As you can probably tell, this isn't working hence why I'm asking the question. Bit of information :- I nee...

WPF, nothing shows up in ListBox

I don't know what I'm doing wrong here. I have a ListBox whose DataContext and ItemsSource are set, but there is nothing in the ListBox when I run my app. When debugging, the first line of my method for getting items for the ListBox never gets hit. Here's what I have: // Constructor in UserControl public TemplateList() { _templat...

XAML animation to bound property

I have the following Rectangle bound to an ever-changing positioning property "RectTop" <Rectangle Canvas.Top="{Binding RectTop}" Height="100" Width="100" Fill="Red" /> Is there I way I can set up an animation/trigger to smoothly animate the rectangle to RectTop whenever that value changes? RectTop changes constantly. RectTop's class ...

How to use INotifyPropertyChanged correctly in WPF/XAML

I have a custom object that I am trying to bind to a control. On that custom object I have implemented the INotifyPropertyChanged interface. I have successfully bound to my object and a property on that object. What I can't figure out is how to go from there. I've been working on this for 2 days now and I still cannot get it working. M...

XAML code re-use (boolean to image binding)

I'd like to be able to reuse this XAML rather than making a copy and changing the binding path. What's the solution for this? I'm want to display a tick or cross for a boolean column in a data grid. <Image> <Image.Style> <Style TargetType="{x:Type Image}"> <Style.Triggers> <DataTrigger Binding="...

Implementing WPF Snap Grid

I am trying to implement a snap grid using WPF and a canvas. I am thinking my math is off because the UIElement won't snap to the grid in the background. Below is the xaml I use to create the grid and the method I use to try and snap the UIElement to the closest grid line. The method used is fired as soon as the mouse button up event ...

open window from xaml

Hi guys, Is there any way to write the ShowDialog window method (e.g. driversWindow.ShowDialog();) via Xaml? I want that pressing a button will open a dialog window define in the Xaml code Thanks Eran ...

Set Label Content with a Dependency property

I have trouble to understand how dependency properties can be used between C# and xaml code. This is a smal code example of my question XAML code: <Window x:Class="WpfChangeTextApplication.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Tit...

Translating Binding from C# to XAML

Hello, i can't get this binding working in XAML. Binding in c# works: public partial class myControl : UserControl { // get singleton instance InfoPool Info = InfoPool.Info; public myControl() { InitializeComponent(); // Test Binding Binding bind = new Binding(); bind.Source = this.Inf...

How do I bind an Entity Object to WPF TextBox?

I feel like I'm missing something very obvious here but I can't get basic binding to work with objects from my EDM. Here's my xaml: <TextBox Text="{Binding Path=receipt.STATUS}" Height="23" HorizontalAlignment="Left" Margin="371,276,0,0" VerticalAlignment="Top" Width="120" /> Here's my View code-behind: public MainWindow() { ...

How to have an enum value in CommandParam in XAML

I have the following enum that represent a state of UI (I use it to enable and disable UI elements): enum Mode { EDIT, RUN, REVIEW } I would like to pass Mode.EDIT to command in CommandParam: <Button Grid.Column="6" VerticalAlignment="Top Command="{Binding Path=ChangeMode}" CommandParameter="{StaticResource local:Mode.RUN}" /...

WPF, cannot bind a property because it says it's not a DependencyProperty, but I registered it

I have a UserControl with a Template property that I've set up as a DependencyProperty: public partial class TemplateDetail : UserControl { public static readonly DependencyProperty _templateProperty = DependencyProperty.Register( "Template", typeof(Template), typeof(TemplateDetail) ...

Expression Blend Error - Value cannot be null. Parameter name: stream

I'm getting the above error when trying to load a User Control xaml file in design view in Expression Blend 4. The xaml itself runs successfully in VS 2010, and I can view the xaml in blend, but not in design view. When viewing the xaml in 'xaml view' the UserControl element is underlined in red. Anybody run across this issue? ...

Can't use silverlight namespace

Whenever I try to reference the following namespace in my XAML, the code compiles and the project starts, but the InitializeComponent method throws an error. Here's the XAML reference: xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" and here's the use of ExtendedVisualStateManager <ei:ExtendedVisualStateManager/...

Syntax to bind to the current dataitem's default indexer in WPF?

I have a Listbox with an itemssource set to an ObservableCollection of DataRow. Let's say each DataRow has 5 columns for this example. In the DataTemplate of the ListBox I have 5 textblocks (1 for each column). My question is how can I bind to an indexer of the row to get the columns value? Here is my attempt but nothing displays so I ...

How to work with mouseover events in Siverlight when I have 2 mouseoverable objects in the same space?

Hi! I have a map (which is made of paths), and above this map, in another canvas, I have some elipses that I intend to use as buttons. I created their mouseover events, but when I tested just the harbor mouseover were triggered (before creating this harbors, the state mouseover worked well). How should I make them both work, in a way tha...

Performance issues with the ScrollViewer

There seems to be a performance degradation when an items collection control is decorated with a ScrollViewer. In the particular application I am working on, there seems to be a big hit to the application when I decorate a VirtualizingStackPanel with a ScrollViewer. I am trying to load up 250 items in this particular container with the h...

WPF Styles for TabControl / TabPanel / TabItem

Here's a newbie question on the WPF TabControl, TabItem and TabPanel. There is a related question on StackOVF with an answer I happily used in my app. Here's a link to the answer, and the code snippet as well: http://stackoverflow.com/questions/2273567/wpf-center-tabitems-in-a-tabcontrol/2273724#2273724 <TabControl> <TabControl.Res...

WPF Button isPressed and isEnabled problem...

Update: using Expression Blend 3 I'm trying to style the IsPressed & IsEnabled(false) property triggers for a class of buttons in a WPF application. Here's a UserControl with a Button using the style... <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/20...

Binding a control to a data class using WPF/XAML

Hello, I am trying to bind a data class to a ListView control in WPF, but can't seem to get it working. I can bind it at run-time and get it working using the following: this.DataContext = DataSet; But, if I try the following in the WPF/XAML is doesn't work which looks like: DataContext="DiscoveredItemContainer" I have tried vari...