Is it possible to have a dependency property "DataContext" in a class that is NOT derived from "FrameworkElement" (but it can be derived from "DependencyObject")?
I already tried and created a class (which I added to Window.Resources), but the DataContext is always null.
Any ideas?
...
Ive created a custom UserControl that contains a single combobox. The currently selected value in the combobox is bound to the custom UserControls Dependency Property.
XAML:
<UserControl>
<ComboBox
ItemsSource="{Binding AllEntries}"
SelectedItem="{Binding SelectedEntry}" />
</UserControl>
Code behind:
public part...
I've some simple code below that uses a ToggleButton.IsChecked property to set the Visibility of a TextBlock. It works fine. Since this doesn't quite fit in with my program's structure, I'm trying to bind the visibility of another TextBlock to a DependencyProperty of "this". It compiles fine, but it produces no effect. I'm doing some...
I'm trying to bind a property in my DataContext to a property in a ValidationRule:
public class ReleaseValidationRule : ValidationRule
{
// I want to bind a value from my DataContext to this property:
public CheckboxViewModels ValidReleases { get; set; }
...
}
Based on this thread, I created the CheckboxViewModels class ju...
Scenario: A VB6 library calls a method in a .NET-Assembly through COM and with that opens a WPF-Dialog, which is contained in another .NET-Assembly that is early bound. This WPF-Dialog got a complex master/detail implementation over a DependencyProperty of type ObservableCollection on this dialog. The DependencyProperty looks something l...
I have two UserControls (uc1 and uc2) loading into a third UserControl (shell). Shell has two properties, uc1 and uc2, of type UserControl1 and UserControl2, and each have a DependencyProperty registered to their own classes called IsDirty:
public static readonly DependencyProperty IsDirtyProperty = DependencyProperty.Register("IsDirty"...
I have a user control, has a Frame as a dependency property
public partial class NavigationBar : UserControl
{
public NavigationBar()
{
this.InitializeComponent();
}
public Frame NavigationFrame
{
get { return (Frame)GetValue(NavigationFrameProperty); }
set { SetValue(NavigationFrameProperty,...
Trying to get radiobuttons binding working but getting a run time error with the code below. Want the radio buttons to act such that only one can be selected at a time, and that they bind correctly in a 2 way fashion. Error text is.
"The invocation of the constructor on
type 'testapp1.MainWindow' that
matches the specified bin...
I have two collections displayed in my WPF application, and I'd like to have elements from one of them disabled in the other. Doing this I'm creating a custom control FilteringListBox that inherits ListBox, and I want to add some handling inside it to disable elements that are set in a collection set through a property on the FilteringLi...
Hello,
I have created an attached behavior that is used to execute a Delegate of type Func<bool> when the behavior is invoked. Below is the dependancy property definition.
public static readonly DependencyProperty SendToDetailBehaviorProperty = DependencyProperty.RegisterAttached("SendToDetailBehavior", typeof(Func<bool>), typeof(ListD...
I have a situation where I have a 3d Model that has a constant rotation animation. When a user touches the screen, I would like the rotation to stop, and the user's control to take over the animation of the rotation.
I tried to do this by pausing the animation, setting the angle property of the rotation locally, then resuming the rotati...
I have created a UserControl with two dependency properties: Value and Color. The Color of the UserControl is dependent on the Value property. For example if Value=0 Color=Blue, Value=0.5 Color=Red and so on. This I have achieved using a custom converter that is bound to the Fill property, like so:
<Ellipse Name="dotForeground" Stroke="...
Hi,
I've been playing with behaviors and I came across a interesting issue.
Here is my behavior:
public class AddNewBehavior : BaseBehavior<RadGridView, AddNewBehavior>
{
public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(AddNewBehavior), new Framework...
The nested ViewModel is set to the MainWindow DataContext:
var mainWindow = new MainWindow();
mainWindow.Show();
mainWindow.DataContext = new
{
MyProperty = new
{
MySubProperty = "Hello"
}
}
It is easy to bind to MySubProperty in XAML:
<Button Content="{Binding MyProperty.MySubProperty}"/>
How can I do this bind...
Is it appropriate to throw an exception from a CoerceValueCallback if a given value is invalid or should only ValidateValueCallback be used for DP-value-validation?
...
I have created a dependency property of type Binary on a RichTextBox which allows me to bind to a FlowDocument which is in binary form (byte[]) within the ViewModel. This works well, the property converts to and back correctly.
Whenever the RichTextBox looses focus then the value of the dependency property is updated with the new binary...
I have setted a property like this:
public static readonly DependencyProperty ValorRegistadoProperty = DependencyProperty.RegisterAttached(
"ValorRegistado",
typeof(string),
typeof(CampoInfo), new PropertyMetadata(new PropertyChangedCallback((d, e) =>
{
System.Diagnostics.Debug.WriteLi...
I'm not sure what I'm doing wrong, but I am attempting to align my user control with the ColumnWidth of my grid using DataBinding and DependencyProperties.
I have a GridView on my Form Page which contains a two instances of a user control (Address). The address usercontrol contains a textlabel "header" so that I can name the user contro...
I am looking at the following xaml:
<Grid x:Name="LayoutRoot" Background="White">
<Button Content="Say Hello..." VerticalAlignment="Center"
HorizontalAlignment="Center"
my:ButtonService.Command="{Binding Path=SayHello}"
my:ButtonService.CommandParameter="Bob"/>
</Grid>
I...
While answering this question I noticed that I have never come across any property which is not a dependency property (WPF Controls, no 3rd party controls). Although, when I started with WPF I remember reading somewhere that "more then 90% of properties of WPF controls are dependency properties".
Can anyone give examples/links of CLR pr...