wpf

WPF Binding to change fill color of ellipse

Probably a simple question but: How do I programmatically change the color of an ellipse that is defined in XAML based on a variable? Everything I've read on binding is based on collections and lists -can't I set it simply (and literally) based on the value of a string variable? string color = "red" color = "#FF0000" ...

TwoWay Binding to ListBox SelectedItem on more than one list box in WPF

I have a scenario where I have a globally available Properties window (similar to the Properties window in Visual Studio), which is bound to a SelectedObject property of my model. I have a number of different ways to browse and select objects, so my first attempt was to bind them to SelectedObject directly. For example: <ListBox Items...

How to set focus to a brand new TextBox which was created as a result of a databinding in WPF?

Hi everyone, I have a WPF ItemsControl that is bound to an ObservableCollection. The XAML: <ItemsControl Name="mItemsControl"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBox Text="{Binding Mode=OneWay}"></TextBox> </DataTemplate> </ItemsControl.ItemTemplate> </...

Applying a pixel shader effect to a portion of an image

I have a ScrollViewer that contains a very large video (16 megapixel @ 10fps) and I want to apply a pixel shader effect to it. Given the size of the images I can't apply the effect directly to the image. So I apply the effect to the ScrollContentPresenter in the control style. Which is great, everything runs nice and fast. However, I'm a...

WPF Update Source Trigger Implementation

I have a custom object Foo with a boolean property called Flagged and when someone successfully types something in a text box it changes flagged to true and updates another textblock on the screen with some text. The problem is I can get it to work on loading the initial data but nothing happens when the user successfully types somethin...

ListBox string displays vertically

My code Add("STRING"); public void Add(string menu) { DataContext = menu.ToString(); } XAML code of Listbox <ListBox x:Name="menubox" ItemsSource='{Binding}' Margin="0,5,0,0" Height="244" Width="240" Background="Silver" BorderThickness="0" > <ListBox.ItemTemplate> <DataTemplate> ...

How to invoke WPF Dispatcher in Nunit?

I want to test an application which renders a text block with a data field value. I would like to get the actual width and actual height, once the rendering completes. Everything works fine. The problem came first, when I tried to test the application. I'm unable to invoke the dispatcher from the test project. Following is the code. ...

How to break an image in triangle pieces.

I'm trying to fragment an image into several smaller triangles in WPF or Silverlight. I've looked around but most of the cropping looks like its done using the clone method which only takes a rectangle. ...

What is the equivalent of OnRender in Silverlight?

I'm working on porting an app from WPF to Silverlight. The app uses custom types derived from FrameworkElement (in WPF) to describe shapes, and text to be rendered on a Canvas. The WPF app root node overrides OnRender() to iterate through a collection of 'child' nodes, calling Render on each child node to build the Visual Tree. Silver...

wpf toolkit calendar, show selected date as today

How to do that? I would like the textbox in the datepicker to show today's date, not by hardcode, perhaps some binding needed? ...

How do I drag and drop between two datagrids in wpf?

For example, dragging a row from a datagrid table to another datagrid table? However the other datagrid table just present the row, it manipulates the data gathered and present it in its own way. I am using wpf toolkit... Can show me a sample example on this? Thanks. ...

Dependency propery Binding Problem

Main WINDOW <Window x:Class="dep2.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:dep2" Title="Window1" Height="300" Width="381"> <Grid> <local:UserControl1></local:UserControl1> <Button He...

How to get the coordinates of an image mouse click in the event handler?

In the following WPF app, I have an Image in a ContentControl. When the user clicks on the image, how can I get the x/y coordinates of where the mouse clicked on the image? XAML: <Window x:Class="TestClick828374.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/win...

WPF: Changing config file user settings at runtime?

Hey I'm trying to change some config file user settings values in my WPF application, but its only working partly. The value is changed correctly and the program runs fine with the value. I can even restart the program and the value is still the one i changed it to. The problem is that when i open the .exe.config file the value is still...

C#: How to kill a singleton window

Hi Everyone I'm working on a WPF application which should be utilizable with two monitors. In the main window is a button which detaches a part of the content in a second window wich can then be used on the other minitor. That second window I implemented as a singleton. That works quite good except that the second window doesn't get des...

WPF Orthographic Camera. Region of view

Hello. I added Orthographic Camera to my project. I want to show my chart on screen proportional. For example height is 4 and width 4 (region from -2 to 2). I set width to 4 and it perfectly fit my square in widht. but i have problem with height. The chart top and bottom is always out of screen space. Why this happens and how to set to...

Image Source In ControlTemplate WPF

I have a ControlTemplate which is for the Button control, in the ControlTemplate I have Image control which is used to displayed in the button, Now I want to set the Image Source at runt time as I have to copy paste the ControlTemplate for each of the button to set new image for new button. Thanks in advance. ...

problem binding ListBox on ObservableCollection<T>

Hello, I have a strange "problem". Could someone explain me why : If I have in an ObservableCollection, twice (or more time) an item with the same value, then the selections of those values in the ListBox won't work properly ? In fact, what the ListBox is doing when I click on an item(Even in single item selection) : It selects the fi...

WPF custom Button using Geometry from resource

Is there a way to use a collection of PathGeometry like these: Path 1 F1 M 170.255,178.837L 170.255,221.158C 170.255,228.917 164.174,230.777 156.745,225.286L 136.003,209.973C 128.572,204.488 128.572,195.512 136.003,190.023L 156.745,174.706C 164.174,169.217 170.255,171.079 170.255,178.837 Z Path 2 F1 M 152.29,174.464L 134.314,187.734C 1...

How to remove all views in region in CompositeWPF/Silverlight

Hi. I want remove all views from my region in Composite. I'm using Silverlight 4.0. And unfortunately, this code crashes with OutOfRangeException inside Composite. List<object> views = new List<object>(_regionManager.Regions["NavigationRegion"].Views); foreach (object view in views) { _regionManage...