user-controls

Command binding is not propagating for control into a DataTemplate of ItemTemplate

我与影子孤独终老i 提交于 2019-12-25 07:59:57
问题 For Command "CommandZoomIn", CanExecute and Execute do not occurs for controls defined into the ListBox ItemTemplate. GraphLcView method "CanExecute" and "Execute" are both called when GraphLcView UserControl is defined directly as child of AnalysisView, but both methods are never called when they are added as Item DataTemplate of a ListBox ItemTemplate. The button with the command is defined in my top level window into a Ribbon. Simplified hierarchy: (Working) Top Level window ->

Does WPF have a set of default binding converters available?

依然范特西╮ 提交于 2019-12-25 07:58:57
问题 When creating WPF user controls I often find myself creating small converter classes when binding values. Often you need to do similar conversions, and it made me wonder whether I might be missing some existing available implementations. Does the .NET library contain any implementations of IValueConverter or IMultiValueConverter? Has there been any attempt made to create a library of reusable value converters? 回答1: There are not many built-in, public are: BooleanToVisibilityConverter

Keep a reference to objects passed to a UserControl

女生的网名这么多〃 提交于 2019-12-25 07:37:29
问题 I created a UserControl that has a ContentControl in it. This ContentControl gets Buttons from the normal .xaml-pages. But depending on some events I need to change this Button's Label or Image but i am getting a NullReferenceException. UserControl1.xaml <Grid> <!-- different Stuff that needs to be around --> <ContentControl Content="{Binding UserControlContent, ElementName=userContent}"/> </Grid> UserControl1.xaml.cs public static readonly DependencyProperty AppBarContentProperty =

How to access ${SRCROOT} in a user script?

一个人想着一个人 提交于 2019-12-25 06:43:19
问题 I have a user script that I would like to be able to access $SRCROOT in order to get a file that is part of the project but can't see to get it to work. If I create a simple user script as so: echo "${SRCROOT}" with the output set to replace selection nothing is output except the newline. Is there a way to access env vars from user scripts? 回答1: Yes, you can access environment variables from user scripts, but the problem is that SRCROOT is a build setting, not an environment variable. It's

Focusable WinRT UserControl with image background

你。 提交于 2019-12-25 06:36:50
问题 I'm having difficulty developing a WinRT control that can display an image as well as be focusable and receive keyboard input. The first part - displaying an image in a UserControl - is straightforward; using a child Rectangle whose background is an ImageBrush works fine. However, calling UserControl.Focus(FocusState.Programmatic) (or any other focus state) does not work - it returns false and focus is not set to the user control. Incidentally, this UserControl is currently being tested

Why does a UserControl cause a Serialization error?

爱⌒轻易说出口 提交于 2019-12-25 05:24:06
问题 I have the following ComboBox in my MainWindow.xaml: <ComboBox ItemsSource="{Binding ComboItemsProperty}" /> In MainWindow.xaml.cs: ObservableCollection<string> ComboItemsField = new ObservableCollection<string>(); public ObservableCollection<string> ComboItemsProperty { get { return ComboItemsField; } set { ComboItemsField = value; } } This works perfectly! I can add items to the Property and successfully Serialize the ComboBox Element. My question is, why is it when I have this EXACT code

Simple usercontrol and MVVM pattern: How to use?

白昼怎懂夜的黑 提交于 2019-12-25 05:21:38
问题 Please help me I have public partial class OrderControl : UserControl { private OrderHeader orderHeader; public Customer selectedCustomer { get; set; } private Customer[] allCustomers; public User selectedManager { get; set; } private User[] allManagers; public OrderControl() { InitializeComponent(); DataContext = this; } ... } And I need one way binding to source: <ComboBox Name="CustomerComboBox" SelectedItem="{Binding selectedCustomer}"/> Is this best way to keep selectedCustomer Property

WPF element host is crashing every second time

拜拜、爱过 提交于 2019-12-25 05:14:57
问题 I have a WPF user control inside windows form project and I have a problem. Every second time my app crashes as element host can't load data in user control. Same thing happens when I put this in WPF project. Every second time my app starts normally. Any idea what could be the problem? This is my user control code: <UserControl x:Class="Fleet_management.Info" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http

Wpf UserControl with its own data context and external dependency property

好久不见. 提交于 2019-12-25 04:45:30
问题 I'm trying to create a simple AudioPlayer control multiple reuse in a solution I'm working on. I have seen numerous example in various posts and blogs around the net and from those have created a small control with four buttons. The xaml is defined thus: <UserControl x:Class="AudioPlayer" 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:/

How can I animate a property dynamically in a Silverlight 4 UserControl?

女生的网名这么多〃 提交于 2019-12-25 04:43:43
问题 I've run into a puzzling limitation in a Silverlight 4 UserControl. What I'm trying to achieve is to have a panel, which slides out from a minimised state when a button is pressed, but the title bar of it should be draggable with which this maximised state can be resized. What I've done for the sliding out is to animate the MaxHeight property of the parent Grid of this panel which works quite well even with no hardcoded Height for the panel, but I don't know how can I make this dynamic.