datacontext

Determine if a WPF DependencyProperty value is inherited

时间秒杀一切 提交于 2021-02-06 19:55:49
问题 Does anyone know how to determine if the value of a WPF property is inherited? In particular, I'm trying to determine if the DataContext of a FrameworkElement was inherited from the parent or set directly on the element itself. 回答1: DependencyPropertyHelper.GetValueSource will give you a ValueSource, which includes a property for retrieving the BaseValueSource. The BaseValueSource enumeration tells you where the DependencyProperty is getting its value from, such as inherited from parent, set

WPF DataContext updated but UI not updated

牧云@^-^@ 提交于 2021-01-28 07:36:20
问题 I have maximum simple app. I want to fill listbox when button pressed. I use binding, window DataContext is updated after some operation, but UI not updated! Here is the code: MainWindow.xaml <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Button Content="Button" HorizontalAlignment="Left" Margin="432,288.04,0,0"

Strange behaviour (or bug?) with ComboBox in WPF when changing DataContext and having bound ItemsSource and SelectedItem

大兔子大兔子 提交于 2021-01-27 06:53:01
问题 I'm trying to debug a strange error in a combobox bound to an itemssource and selecteditem. It's driving me crazy. The problem arise when changing selected tabitem in which the combobox exists. (Actually it's only when changing the DataContext of the ComboBox). The SelectedItem-binding has a custom validationrule to give error if value is null. The problem is that wpf calls my custom rule when switching tabitems (DataContext) and tries to validate a value of null, even though the selecteditem

UWP Databinding: How to set button command to parent DataContext inside DataTemplate

自古美人都是妖i 提交于 2020-11-28 07:09:20
问题 Short explanation of need: I need to fire the command of a button inside a DataTemplate, using a method from the DataContext of the ViewModel. Short explanation of problem: The templated button command only seems to be bindable to the datacontext of the item itself. The syntax used by WPF and Windows 8.1 apps to walk up the visual tree doesn't seem to work, including ElementName and Ancestor binding. I would very much prefer not to have my button command located inside the MODEL. Side Note:

UWP Databinding: How to set button command to parent DataContext inside DataTemplate

狂风中的少年 提交于 2020-11-28 07:08:11
问题 Short explanation of need: I need to fire the command of a button inside a DataTemplate, using a method from the DataContext of the ViewModel. Short explanation of problem: The templated button command only seems to be bindable to the datacontext of the item itself. The syntax used by WPF and Windows 8.1 apps to walk up the visual tree doesn't seem to work, including ElementName and Ancestor binding. I would very much prefer not to have my button command located inside the MODEL. Side Note:

UWP Databinding: How to set button command to parent DataContext inside DataTemplate

℡╲_俬逩灬. 提交于 2020-11-28 07:07:19
问题 Short explanation of need: I need to fire the command of a button inside a DataTemplate, using a method from the DataContext of the ViewModel. Short explanation of problem: The templated button command only seems to be bindable to the datacontext of the item itself. The syntax used by WPF and Windows 8.1 apps to walk up the visual tree doesn't seem to work, including ElementName and Ancestor binding. I would very much prefer not to have my button command located inside the MODEL. Side Note:

UWP Databinding: How to set button command to parent DataContext inside DataTemplate

99封情书 提交于 2020-11-28 07:07:12
问题 Short explanation of need: I need to fire the command of a button inside a DataTemplate, using a method from the DataContext of the ViewModel. Short explanation of problem: The templated button command only seems to be bindable to the datacontext of the item itself. The syntax used by WPF and Windows 8.1 apps to walk up the visual tree doesn't seem to work, including ElementName and Ancestor binding. I would very much prefer not to have my button command located inside the MODEL. Side Note:

UWP Databinding: How to set button command to parent DataContext inside DataTemplate

纵然是瞬间 提交于 2020-11-28 07:06:48
问题 Short explanation of need: I need to fire the command of a button inside a DataTemplate, using a method from the DataContext of the ViewModel. Short explanation of problem: The templated button command only seems to be bindable to the datacontext of the item itself. The syntax used by WPF and Windows 8.1 apps to walk up the visual tree doesn't seem to work, including ElementName and Ancestor binding. I would very much prefer not to have my button command located inside the MODEL. Side Note:

Unable to create an object of type 'MyContext'. For the different patterns supported at design time

 ̄綄美尐妖づ 提交于 2020-05-26 11:18:08
问题 I have ConsoleApplication on .NET Core and also i added my DbContext to dependencies, but howewer i have an error: Unable to create an object of type 'MyContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728 i've added: var context = host.Services.GetRequiredService<MyContext>(); Also i've added private readonly DbContextOptions<MyContext> _opts; in my Post Class: using (MyContext db = new MyContext(_opts)) { db.Posts.Add(postData);

How to cache DataContext instances in a consumer type application?

▼魔方 西西 提交于 2020-02-03 04:34:07
问题 We have an application using SDK provided by our provider to integrate easily with them. This SDK connects to AMQP endpoint and simply distributes, caches and transforms messages to our consumers. Previously this integration was over HTTP with XML as a data source and old integration had two ways of caching DataContext - per web request and per managed thread id. (1) Now, however, we do not integrate over HTTP but rather AMQP which is transparent to us since the SDK is doing all the