wpf-usercontrols

accessing derived class from base class object problem

I have a kind of weird situation ... I have a User Control in WPF witch in turn has some other User Controls attached to it, then I have a huge C# code file with a big algorithm which needs access to the User Control UI Elements and methods, this hole process works with a Timer which sends data to the C# code file algorithm from the Use...

WPF, updating status bar in main window from within UserControl

I have a StatusBar in my main window, and I also have a copy of a UserControl in my main window. From within event handlers in my UserControl, I want to update the StatusBar in the main window. What would be the best way of doing this? Is there a way of getting access to the instance of my main window from object sender or RoutedEvent...

WPF, share methods between two UserControl classes

I have two UserControl classes, RequiredFields and OptionalFields. I wanted to have a base class, Fields, that would inherit from UserControl and contain methods that both RequiredFields and OptionalFields would use. However, when I try to do that, I get the following error: Partial declarations of 'MyNamespace.OptionalFields' must...

WPF/XAML: How to change a borders background with a colorpicker

Hello everybody, i have a xaml resource file with some definitions of datatemplates. In one datatemplate i have a border background bound to a property of its dataobject. I also have a colorpicker user control which is part of the contextmenu of the border. Now i'm trying to bind the dependency property "CustomColor" of the colorpicke...

Why is a custom property in a UserControl not set when the control is used in a DataTemplate?

I have a UserControl that has a custom DependencyProperty. When I use the UserControl from inside a DataTemplate, I cannot set the value of the DependencyProperty. If I use the UserControl directly in a window, then the DependencyProperty works fine. I apologize for the long post, I simplified the code to the minimum that still shows the...

WPF: Validation on a UserControl

Hi everyone, this is probably very simple, but I can't seem to figure it out... I'm currently using a UserControl to replace form fields to input text on a touch screen. This UserControl is essentially a Button displaying the current text and a pen icon, opening a separate screen keyboard window when pressed. It also needs to validat...

WPF DataContext ... looking for the simplest syntax.

In the following XAML UserControl I am binding a few items to properties in the UserControl's linked class. <UserControl x:Class="Kiosk.EventSelectButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Kiosk" Height="130"...

Wpf CustomButton Toolbar Style

Hello, i have created a UserControl to make a ImageButton. But i replaced the the UserControl Item with a Button. < Button x:Class="myimagebutton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:imagebutton"> <Grid x:Name="grdButton...

WPF UserControl HitTest

I have the following user control: a dot and its name: <UserControl x:Class="ShapeTester.StopPoint" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas...

WPF Databinding Singleton Properties (From Multiple Windows)

Edit 3: TLDR-Version I have a singleton DependencyObject that I'm binding UserControls to. Some of the UserControls are in the main window, some of them appear in a separate window (the settings window). The ones that appear in the settings window do not bind correctly and do not affect the values in the singleton. I have a singleton...

WPF GetWindow casting error

I have a user control hosted inside of another user control. I want the child control to be able to set the "enabled" state of buttons to false (among other things) in the parent. I try GetWindow but am getting the error Cannot convert type 'System.Windows.Window' to 'ucContainer'. Is there an equivalent I could use for a user control...

How do I make my WPF User Control's dependency properties update my view model?

Hi all, I'm trying to create a user control with dependency properties to bind to. Internally I have a ComboBox that is bound to these same properties, but the binding only works one way. The ComboBox fills from the ItemsSource, but SelectedItem doesn't get updated back to the viewmodel I'm binding to. A simplified example: This is th...

WPF usercontrol dynamic itemsSource

I've got a UserControl with a ObservableCollection member. In the UserControl i have a ListBox and i want the ListBox ItemsSource to be the the UserControls ObservableCollection. UserControl: public partial class Timeline : UserControl { public ObservableCollection<TwitterStatus> Tweets = new ObservableCollection<TwitterStatus>();...

TranslateTransform and Canvas.SetLeft() a UserControl problem!

Hi there! I'm having trouble to translate a usercontrol in my project, i'm implementing a drag & drop application. Here is the layout my program, the Canvas named Buttons holds the Usercontrol that will be dragged and dropped. When I drop the object, I want to appear in another position defined me. I've tried to use Canvas.SetLeft(...

Represent a City in WPF

Say, I build a dynamic map in WPF. I need to represent in this map locations(say, cities). The representation of a city is simple: a dot (circle or image) and the text. Both text and dot image are customizable. What would you recommend using as a CityControl in WPF? Examples: A UserControl having an <Ellipse>(or picture) and <...

Binding XML file to a UserControl

I want to bind the data from my XML file to my userControl. So far I have: XML file: <?xml version="1.0" encoding="utf-8"?> <testData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <pumps> <pump> <speed value="1200"/> <color value="Black"/> ...

WPF control with many GridViews

I have a WPF usercontrol that will dynamically have any number of gridviews. Each is essentially the exact same except for the ItemsSource. Therefore each have the same columns and the same RowDetailsTemplate. To be specific what I am actually doing is settings the columns to the bound values and then setting the RowDetailsTemplate to th...