wpf-binding

2 Properties in One Binding?

Can I combine 2 elements in one biding? <Canvas> <Ellipse Fill="Black" x:Name="dot1" Width="16" Height="16" Canvas.Left="124" Canvas.Top="133"/> <Ellipse Fill="Black" x:Name="dot2" Width="16" Height="16" Canvas.Left="221" Canvas.Top="40"/> <Line Stroke="Black" x:Name="line1" X1="{Binding ElementName=dot1, Path=(Ca...

WPF Datagrid SelectionChanged event is triggering Multiple times while loading the rows.

Hi, When i use DataGridComboBoxColumn in my WPF DataGrid, the DataGrid SelectionChanged event is triggering multiple times based on the number of rows while loading the rows in the WPF DataGrid. How can i stop this? Because of this I am facing Performance issue. ...

WPF StringFormat databinding text not appearing

I am trying to get the header text of a TreeviewItem to be set in the binding to an XML source. Everything is working fine except the only thing that appears in the header is the text I'm binding to and nothing else in the string format. Example: <HierarchicalDataTemplate x:Key="LogDataTemp" ItemsSource="{Binding Path=log}"> <Tree...

WPF MVVM Button Control Binding in DataTemplate

I've seen other questions that deal with this, but never any explicit code describing the fix. I can't get a button inside of my ItemTemplate to bind to ANY command anywhere. Very frustrating. I am a complete MVVM newbie, btw. Here's my Window XAML. <Window x:Class="RET.CMS.Printing.App.MainWindow" xmlns="http://schemas.microsoft.c...

Building a DataTemplate in C#

I am trying to build the following DataTemplate in C# <DataTemplate x:Key="lbl"> <!-- Grid 2x2 with black border --> <Border BorderBrush="Black"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefin...

Visible Binding Based On Bound Object and Model Properties

I ran in to the unique situation today where I needed to bind the Visible property of a button in a DataGridRow to be based on both a property of the bound object and of the model backing it. XAML: <t:DataGrid ItemsSource="{Binding Items}"> <t:DataGrid.Columns> <t:DataGridTemplateColumn> <t:DataGridTemplateColum...

unable to set focus to datepicker using attached property in wpf

Hi Experts, I have a custom datepicker with me and i am trying to set focus to this using attached property. I have the toolkit version 3.5.50211.1 which was released on Feb 2010. The focus is working fine when i do DatePicker.Focus(); in my code. My custom datepicker code is as follows: -- My DatePicker using System.Collections.Gene...

Binding not working... (WPF) "x:Name" problem?

I have two buttons, and need to link them with a line. I bind the Line coordinates to the button positions. I need to add this binding by code. In XAML this work very well like this: <Button x:Name="button1" Width="10" Height="10" Canvas.Left="150" Canvas.Top="150"/> <Button x:Name="button2" Width="10" Height="10" Canvas.Left="250" ...

WPF binding for a converter not working

I have a custom converter that has a DefaultText property. All my converter does is return the DefaultText if the string is null or empty. I can't seem to get it to work though. Here's what I've got. This is the converter class. public class DisplayValueConverter : DependencyObject, IValueConverter { public static readonly Dependenc...

WPF DataTemplate and Binding

I am DataTemplating a listbox's itemsource to display a label and combobox. In the, datatemplate I am assigning a new itemssource to the combobox but cant get it to work. Or Ideally, how can I bind the combobox in a datatemplate to a different source. Thanks. Mani UserControl: <DockPanel> <ListBox x:Name="lstBox" ItemsSource...

WPF DataTemplate and Binding - Is this possible in xaml ?

I am DataTemplating a listbox's itemsource to display a series of comboboxes. I want to give the 'DisplayMemberPath' of the combo to a property, which is in a different source than its own 'ItemsSource'. (Assuming DisplayMemberPath is just a string representing name of a property, I am getting this from the user). I have achieved this wi...

RadDatetimepicker capture the date

I am working with WPF and C#. I want to fire an event when the user modifies or selects a date on my raddatepicker control. What event handler should I be using for this? I want to be able to convert this captured date to a SQL server 'datetime' variable for use in the backend. ...

WPF - Creating a dynamic datagrid in xaml by datatemplate

I am trying to create a DataGrid by datatemplates. The reason is I want the columns to be dynamically created but all in xaml and not in code behind. I get a List based on which I want to create my grid columns in xaml. class GridColumnElement { public string HeaderCaption { get; set; } public string PropertyName { ...

Bind to ActualHeight does not work...

I try to create a custom control, havig a semitransparent rounded background: <Canvas> <TextBlock x:Name="StopText" Text="Some test text"/> <Rectangle Fill="SkyBlue" Width="{Binding Source=StopText, Path=ActualHeight}" Height="20" RadiusX="5" RadiusY="5" Opacity="0.2"/> </Canvas> ...

How to access Generated WPF controls after Data Binding

Please consider the following XAML code: <ListBox Name="listBox1" ItemsSource="{Binding}" > <ListBox.ItemTemplate> <DataTemplate> <Border Name="border1"> <TextBlock Text="{Binding}" /> </Border> </DataTemplate> </ListBox.ItemTemplate> </ListBox> and we assign a simple arr...

WPF Treeview Binding, HOw do i display different data class as a Nodes Child ?

Hi, Im trying to display a group (file extension and icon)(parent) then all of the files found in that group (child) in a WPF Treeview. I can get the groups to show in the treeview, each with an icon and text, however I dont understand how to display the files as children of the group. Here is the GroupInfo class, the problem is it cont...

How can I know if WPF binding will happen?

I've got a TextBox whose Text property is bound to a property on my view model on LostFocus event. I've noticed that when I move out of this TextBox without changing the value that was already in there, the binding does not happen. I've got a PreviewKeyDown event handler on the TextBox to handle Enter, Up/Down arrow key presses so that ...

Custom DependencyProperty issue

I did a test on custom dependency properties on WPF userControls, and does not work... Please help. Task: Having an UserControl - MyCircle, build the CenterX and CenterY bindable properties. Here is my code: MyTestCircle.xaml <Canvas x:Name="mainCanvas" Width="100" Height="100"> <Ellipse x:Name="myCircle" Fill="Red" ...

Why doesn't this WPF binding work?

I'm having trouble getting a binding to work. I have created a completely fruitless example to demonstrate my problem. It goes like this... I have a collection of widgets that I want to be able to define in XAML. This collection will be associated with a UserControl. In the XAML I want to bind the 'Name' property of the widgets to bits ...

Need to override default ContentTemplate for string content.

If I have a Menu defined like this: <Menu> <MenuItem Header="Stuff" /> </Menu> When this gets rendered, the ContentPresenter inside of the MenuItem ends up with content like this: <TextBlock Text="{Binding}" /> which means that it inherits the default styling of TextBlock, which isn't always desirable. I know that I can change my ...