Questions tagged [dependency-properties]

A property in WPF and Silverlight that can be set through methods such as, styling, data binding, animation, and inheritance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
38 views

WPF binding to custom control dependency property does not trigger property change

I am having trouble binding to a dependency property on a custom control. This is my custom control. It's basically a textbox that only allows numeric input and exposes a "Value" dependency ...
Elias Verstappe's user avatar
0 votes
0 answers
66 views

C# using a method from a class to another class, instance, DependencyProperty.Register error

I'm having some issues here. So I wrote this method in a class named MainWindow, that exports logs of an app to a txt. Honestly I dont know if its good but anyways we will see. public void exportLogs (...
PinkGoat_'s user avatar
0 votes
0 answers
57 views

ObservableCollection binded to another ObservableCollection does not fire CollectionChanged

I have ControlA hosting ControlB, both of them have DependencyProperty of type ObservableCollection, the nested control's (ControlB) property is binded to parent (ControlA) property, if something is ...
Notrum666's user avatar
  • 295
0 votes
0 answers
40 views

What is the proper way to disallow an invalid WPF DependencyProperty change?

My custom control shows an image. It has event handlers that allow the user to pan/drag the image and zoom it in or out. It exposes two DependencyProperties ImageCenter - The current center point ...
Joe's user avatar
  • 5,622
0 votes
1 answer
49 views

Update one Dependency Property based on another

I have a custom control I have set up in c#/wpf. I am using Dependency properties for items, some of these are optional, but my current code seems very convoluted: public class PopupMenu : ...
Richard Gale's user avatar
  • 1,844
0 votes
2 answers
100 views

Bind attached property in ControlTemplate

<Style x:Key="DeckButton_Help" TargetType="{x:Type Button}"> <Setter Property="Height" Value="22"/> <Setter Property="Padding" ...
Ashot's user avatar
  • 10.8k
2 votes
1 answer
73 views

Why all TextBoxes in ItemsControl use the last dynamically-added ValidationRule?

I have a custom TextBox that adds MinMaxValidationRule when both Min and Max properties are set public class TextBox2 : TextBox { public static readonly DependencyProperty MinProperty = ...
Muhammad Sulaiman's user avatar
-2 votes
1 answer
33 views

Correct way to bind delegate to DependencyProperty?

I have the following UserControl, trying to accept a user provided Validation function. The code "seems" to be fine, Designer did not complaint, compiled fine, and the application ran.. but ...
codenamezero's user avatar
  • 2,793
0 votes
1 answer
29 views

IsChecked binding for a checkbox inside a usercontrol is not fi [duplicate]

In the UserControl.xaml: <UserControl x:Class="OurNameSpace.SystemCalibration.Controls.PortSelector" xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation ...
user12270575's user avatar
0 votes
1 answer
43 views

How to change a dependency property of a user control by pressing a button that belongs to the user control?

Let's say we have a user control with a simple dependency property named Percentage of type double. Value of Percentage is being shown in a textblock. Also there is a button that must change the ...
Heartbane's user avatar
0 votes
1 answer
30 views

How can I bind a ValueRange Maximum and Minimum using Dependency property?

I'm working with a user control that includes a shared DataGrid used by multiple user controls. To customize the 'Maximum' and 'Minimum' values for each user control, I've implemented Dependency ...
abdou_dev's user avatar
  • 827
0 votes
0 answers
47 views

C# WPF Dependency Property get and set methods not executed? [duplicate]

Just started a WPF study in combination with MVVM. I think I understand the basics of it and made a simple app with one checkbox with binding to a MainWindowViewModel class. The first version was with ...
Aad Slingerland's user avatar
0 votes
0 answers
39 views

Strategy to backup a dependency property and restore its value [duplicate]

I have a string dependency property that I want to apply a "filter" to. public string backup = string.Empty; public static readonly DependencyProperty StringInTextBoxProperty = ...
Hans GD's user avatar
  • 52
0 votes
1 answer
216 views

@PropertySource returns 'Properties location not resolvable: (No such file or directory)'

I have a config file that is meant to use @PropertySource to set values. However it seems like it is not working (below) @Configuration @PropertySources({ @PropertySource(value = "file:/...
Rachel Kim's user avatar
0 votes
1 answer
42 views

Editting a member within a class does not invoke PropertyChangedCallback of DependencyProperty

I’m developing a WPF desktop application, utilizing MVVM framework. I have an enum and a class defined as follows: public enum eTypes { A, B }; public class MyClass { public eTypes MemberEnum { ...
Michael Nguyen's user avatar
0 votes
0 answers
73 views

Maven Friendly version is not working in multimodule setup

I have Maven multi module project where i have hardcoded the pom version in main pom and all of the child pom's as well. But am trying to use the maven-ci-friendly-version to my project. So i have ...
Ramesh Thiyagarajan's user avatar
1 vote
1 answer
126 views

Running a fyne/golang test job, error with dependencies

I am running a trial example, it gives an error. Some kind of problem with dependencies. package main import ( "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "...
Ilya 's user avatar
  • 11
0 votes
2 answers
74 views

Binding problems between an usercontrol and its parent (another usercontrol) MVVM

I am creating an UserControl with 2 RepeatButtons and one TextBox. So problems begin when i want to Bind some properties.... FYI i am using Caliburn.micro as Framework.. i need to have the value of ...
Frenchy's user avatar
  • 16.5k
0 votes
1 answer
20 views

Set DependencyProperty's PropertyMetadata to a TextBox's inherited Foreground Color, FontSize

In the following c# wpf Code, I want to set the PropertyMetadata of the PlaceholderFontSize property to the inhereted TextBox's FontSize or Foreground The following code is a custom TextBox that has ...
Salmy's user avatar
  • 47
1 vote
2 answers
73 views

NavigationView.ClearValue(NavigationView.MenuItemsProperty) always throws System.ArgumentException

var temp = new NavigationView(); temp.ClearValue(NavigationView.MenuItemsProperty); // System.ArgumentException: 'Value does not fall within the expected range.' // Exception occurred: 'System....
appletree5641's user avatar
1 vote
1 answer
34 views

SetBinding to custom dependency properties is not updated after the initial update

// MainWinodw.xaml.cs namespace TestApp { [ObservableObject] public sealed partial class MainWindow : Window { [ObservableProperty] private Brush _myBrush = new ...
appletree5641's user avatar
0 votes
1 answer
74 views

Binding for a property of a Converter

I have a problem in Binding the value of the parameter of a class. I defined the below converter to change the values of the visual components using a unit converter class. [ValueConversion(typeof(...
Mohicode's user avatar
0 votes
1 answer
28 views

SelectedItem is not properly set in the ViewModel even though the dependency callback method is being fired

I am extending ComboBox control to include a label in front, via dependency property as per below: ComboBoxEx.xaml.cs public partial class ComboBoxEx : UserControl { public ComboBoxEx() ...
Graviton's user avatar
  • 82k
0 votes
0 answers
20 views

Changing a DependencyProperty's local value without erasing bindings [duplicate]

Consider this standard implementation of a DependencyProperty e.g. on a custom UserControl: public static readonly DependencyProperty MyStringProperty = DependencyProperty.Register( nameof(...
mike's user avatar
  • 1,664
0 votes
0 answers
27 views

How to set the DataContext of a user control when another DependencyProperty changes [duplicate]

I'm working on a WPF application that uses a UserControl. The UserControl is called ReportControl; here's the XAML: <UserControl x:Class="ReportManager.Controls.ReportControl" ...
Tony Vitabile's user avatar
0 votes
1 answer
90 views

WPF FindAncestor binding finds source in Release, fails in Debug

I have a binding error that makes no sense. It always works in Release Mode. It sometimes -- only sometimes -- fails to find the source via FindAncestor in Debug Mode Its for Style for a WPF Path ...
Joe's user avatar
  • 5,622
-2 votes
2 answers
297 views

Create dependency property for WPF Window itself in its code behind xaml.cs

I have a WPF window which I have changed its borders, title bar and buttons for a custom one. Separately in a ResourceDictionary I have defined the Style that I want to apply to my WPF window. Then I ...
Kiraski's user avatar
  • 27
0 votes
1 answer
35 views

Cannot bind slider value in DataGridTemplateColumn

I am trying to create a DataGrid with two text columns and a template column as follows: <UserControl ... Name="TcpNtcpSliders" ...> <DataGrid Name="MinTcpDataGrid&...
Anno's user avatar
  • 801
0 votes
1 answer
26 views

Nested UserControl(s) throw "Property was already registered by"

I have this UserControl xaml: <Grid> <Separator x:Name="sep" VerticalAlignment="Center" Height="10" /> </Grid> and its code behind where I ...
Gian's user avatar
  • 17
0 votes
0 answers
20 views

How to constrain values in React

My problem domain is in AvaloniaUI, but I think it's actually a C# question. I have two C# properties Scale and LogScale which are related mathematically. One is the log of the other. Basically this ...
Sonicsmooth's user avatar
  • 2,703
0 votes
0 answers
43 views

How to setup progam.cs and services in a xUnitProject

This should be a simple enough question but I'm not able to find a working answer to it. I use automapper in my application and inject it from program.cs builder.Services.AddAutoMapper(typeof(...
Anders's user avatar
  • 499
1 vote
0 answers
217 views

PropertyChangedCallback called before Binding/ViewModel updates

I am currently building a control library for WPF, WinUI3 and UWP. I use custom ContentControls for my controls with DependencyProperties. On some DependencyProperties (e.g. IsChecked) I have to use a ...
IcySnex's user avatar
  • 33
-1 votes
1 answer
136 views

Best practice for dependency properties with reference type as default value

I have the following DependencyProperty: public static DependencyProperty ItemsProperty = DependencyProperty.Register(nameof(Items), typeof(ObservableCollection<ContentControl>), typeof(Group), ...
Cryosys's user avatar
0 votes
0 answers
342 views

Flutter prop drilling problem here, I'm trying to return cart item count widget build on my home screen for each specific item

I have successfully built a home screen that can navigate to cart page and show items in cart but I now struggle to display that same item count in the home screen for each items. The methods I'm ...
Tiisetso Dinoko's user avatar
-2 votes
1 answer
87 views

View model property bound to a dependency property from another user control is never called every time the dependency property is set to true

I have a WPF User Control in which I place another WPF user control. Note that I only post the relevant things here to understand it. <UserControl x:Class="myApp.UI.Views.myMainView" ...
Willy's user avatar
  • 10k
0 votes
1 answer
76 views

Using named in reusable WPF control

I recentrly discovered "reusable controls" in WPF and I have a project where they seem to provide me with a solution to a problem I have. Let me sketch the situation: I need to make several ...
Elias Verstappe's user avatar
-1 votes
2 answers
237 views

Why is the root element of MainWindow Window instead of MainWindow?

I notice that the root element in any XAML file (in WPF) seems to be one of: Window Page UserControl ResourceDictionary Application I tried to change the root element to local:MainWindow, but then ...
Obsidian's user avatar
  • 809
-2 votes
2 answers
280 views

WPF - Properties of ItemsSource to Dependency Properties

Background I am making a custom control that has multiple ListBox's. I want to make this control MVVM compliant, so I am keeping any XAML and the code behind agnostic with respect to any ViewModel. ...
jgrmn's user avatar
  • 144
0 votes
0 answers
14 views

WPF binding property of viewmodel to dependency property of custom textbox control [duplicate]

I need a textbox with an additional Property "IsValid" of type boolean. I then want to bind that DP to a Property of a ViewModel of the View thats containing the custom textbox. Im blocked ...
JakobSailer's user avatar
0 votes
2 answers
88 views

How to bind dependency property to DataGridComboBoxColumn in UserControl?

The XAML of my UserControl with name "Clinical_Protocol": <Grid> <DataGrid Name="ClinicalProtocolDataGrid" ItemsSource="{Binding ...
Anno's user avatar
  • 801
0 votes
1 answer
98 views

Dependency Property in ContentDialog works only in one direction

I got a problem concerning ContentDialogs in WinUI 3. I have a Panel opening a ContentDialog. The ContentDialog contains a TextBox. The Panel has a property that should store the Text that has been ...
tiko's user avatar
  • 17
0 votes
0 answers
32 views

Update CustomControl on ItemsSource item changed

Extending Calendar control, I have added ItemsSource DependencyProperty to allow me to display ToolTips and highlight CalendarDayButtons using provided Color. ItemsSource is of type IEnumerable<...
James0n's user avatar
  • 45
1 vote
1 answer
74 views

Dependency property for ItemsSource column to set DataTrigger condition

How would I properly bound to ItemsSource column via Dependency property of control (Datagrid), in order to set It's DataTrigger working? My goal that works without dependency property: <Style ...
Lucy82's user avatar
  • 662
-1 votes
1 answer
268 views

How to bind dependency property of ICommand of ItemsControl member to parent view model?

I have a custom user control that has a checkbox and a button with backing dependency properties. I also have a window with an ItemsControl and I bind that control's "ItemsSource" to an ...
Router's user avatar
  • 45
0 votes
0 answers
72 views

Bound ListView won't accept List<VisualStateGroup> as ItemsSource in WinUI 3. Any idea why?

I am using version 1.1.5 of the Windows App SDK to create a Desktop application in WinUI 3. I've created a Page on which I have a ListView that I'd like to have display information from a List of ...
aturnbul's user avatar
  • 367
0 votes
1 answer
112 views

Dependency Property command's CanExecute() not updating

I have a user control and within I defined the following property: public string MyProperty { get { return (string)GetValue(MyPropertyProperty); } set { SetValue(MyPropertyProperty, value);...
Anno's user avatar
  • 801
0 votes
1 answer
427 views

WPF MVVM Dependency property binding not working

I'm using a beavior in a TextBox control to filter input via a regex. For this I added a dependency property to get the regex value. When I set directly in xaml the value, It works properly but when I'...
Yannick's user avatar
  • 182
0 votes
1 answer
1k views

Create a CustomControl in C# WinUI 3 containing other CustomControls

I'm new both to WinUI and XAML and I'm creating a WinUI 3 Library that contains various CustomControl. They're all independent and can be used stand alone. But one of those controls, is made by ...
Cheshire Cat's user avatar
  • 1,951
0 votes
2 answers
234 views

Binding data in custom control

I have a custom control myCustomControl.Xaml <UserControl.Resources> ... </UserControl.Resources> <ComboBox Name="myCustomComboBoxParent" someId = "{...
Durinko's user avatar
  • 61
1 vote
0 answers
92 views

WPF coerced DependencyProperty value change does not update that property's binding

I am using a custom control in my WPF application, which is a subclass of the standard TextBox, meant for holding a number within a certain allowed range. This control has three dependency properties -...
flibbo's user avatar
  • 124

1
2 3 4 5
46