dependency-properties

Custom attached property of ResourceDictionary with implicit declaration syntax?

好久不见. 提交于 2019-12-14 04:27:20
问题 As you know a FrameworkElement has a property of type ResourceDictionary named Resources , in XAML we can declare it easily like this: <FrameworkElement.Resources> <SomeObject x:Key="someKey"/> <SomeOtherObject x:Key="someOtherKey"/> </FrameworkElement.Resources> It's some kind of implicit syntax, all the elements declared inside will be added to the ResourceDictionary . Now I would like to create an attached property having type of ResourceDictionary , of course a requirement of being

WPF, property in ValidationRule never set

我与影子孤独终老i 提交于 2019-12-14 03:14:30
问题 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 just to act as a wrapper for a List<CheckboxViewModel> so that the list could be a DependencyProperty so that I could bind to it. However, in my Validate method on my

WPF: animate a custom dependency property?

断了今生、忘了曾经 提交于 2019-12-13 20:41:29
问题 Let's say that I've defined a dependency like this: public class MySampleClass {public static DependencyProperty MyDoubleProperty = DependencyProperty.Register("MyDouble", typeof(double), typeof(MySampleClass)); public double MyDouble { get { return (double)GetValue(MyDoubleProperty); } set { SetValue(MyDoubleProperty, value); } } } I'd like to apply a DoubleAnimation to this value. How can I do this? Always before, I've used DoubleAnimations by calling the BeginAnimation method of a

WPF Binding to DependencyProperty of UserControl in DataTemplate is not working

时光总嘲笑我的痴心妄想 提交于 2019-12-13 18:24:16
问题 i have a custom userControl with DPs and have the problem that the binding to these properties only works if i use the controls outside of datatemplates. Outside of Datatemplates works the usercontrol great. XAML to Test the UserControl in a DataTemplate <GroupBox Header="DataTemplate" Padding="5"> <ItemsControl ItemsSource="{Binding Dummies}"> <ItemsControl.ItemTemplate> <DataTemplate DataType="local:Dummy"> <StackPanel Orientation="Horizontal" Margin="2"> <common:QuarterPicker

how to propertly use CoerceValueCallback in a custom WPF usercontrol

心已入冬 提交于 2019-12-13 17:41:24
问题 I have created a user control, the other members of my team simply place it on their view and they can then dynamically create an ObservrableCollection of buttons and bind to it (a ribbon bar but highly customized to our needs), it handles placement, style etc. It works just fine and totally fits the need for our project however it only works upon initial load, I did some digging and realized that it was because I only had a PropertyChangedCallback in the FrameWorkMetaData and I didn't set up

Add Dependency Property to existing .NET class

本秂侑毒 提交于 2019-12-13 09:36:52
问题 IN a WPF project I have a bunch of controls in which I would like to be able to set individual Margin properties and conserve the other values. So, I would like to avoid setting the complete margin to a new Thickness ( Margin="0,5,0,15" ). Because many margin's are set from styles etc. But in individual cases I would like to deviate from the generic styles for certain controls. I thought, why not register a couple of new dependency properties on the .NET class FrameWorkElement like so (for

How to Override PropertyChangedCallback of a predefined Dependency Property ItemsSource in a WPF ItemsControl

若如初见. 提交于 2019-12-13 09:28:27
问题 How to Override PropertyChangedCallback of a predefined Dependency Property ItemsSource in a WPF ItemsControl . I developed a WPF Custom Control inherited from ItemsControl . In that I used the predefined Dependency Property ItemsSource . In that I need to monitor and check data once the Collection gets updated. I searched a lot in google, but I can't able to find any related solution to fulfill my requirement. https://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol

Combobox show and hide ComboBox items in WPF

試著忘記壹切 提交于 2019-12-13 09:08:28
问题 ComboBox might have a lot of items. This is the scenario i would like to achieve: I have to create a custom ComboBox which has a "More" button which located at the last of the ComboBox items. If the ComboBox contain of 20 items, initially, when the ComboBox is clicked and the drop down list is shown, there are only 10 items and a "More" button under the 10th items are displayed. Whenever the "More" button items is clicked, the "More" button will turn into "Less" and the drop down list will

How to create this shared class member or property

ε祈祈猫儿з 提交于 2019-12-13 05:46:38
问题 I have the following class that is referenced by my XAML. This class sits with a bunch of attached properties and behaviors that belong to buttons, so it is on the UI side of things. A few of these behaviors set current_cell_match and each of these behaviors has it's own class, that is why I placed it into a static class so that it can be shared. public static class SearchVariables { public static DataGridCellInfo current_cell_match; public static void setCurrentCell(Object dgi,

DataTrigger does not fire on a derived class of a Button

此生再无相见时 提交于 2019-12-13 04:48:26
问题 We have a ton of Buttons with an Icon and Text across the App, and I am trying to extract a common style for all of them. I came up with this idea of deriving from a Button and have a couple of dependency properties. This custom button class has a style common to all the Buttons in our Application. My Custom Button definition: <Button x:Class="UIElements.Controls.CustomToolBarButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx