binding

Binding to ActualHeight does not work

て烟熏妆下的殇ゞ 提交于 2019-12-22 16:40:40
问题 I tried to create a custom control, having a semitransparent rounded background: <Canvas> <TextBlock x:Name="StopText" Text="Some test text"/> <Rectangle Fill="SkyBlue" Width="{Binding Source=StopText, Path=ActualHeight}" Height="20" RadiusX="5" RadiusY="5" Opacity="0.2"/> </Canvas> The problem is that I can't, probably, bind to the ActualHeight / ActualWidth properties, cause they are not dependency ones. What to do to mantain the rectangle and textbox of same size? 回答1: The correct binding

FrameworkPropertyMetadataOptions in Silverlight

百般思念 提交于 2019-12-22 14:03:51
问题 Is there an equivalent of FrameworkPropertyMetadataOptions in Silverlight 5? I want to be able to FORCE a two way binding from my User Control like this: public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", typeof(object), typeof(SearchableGridView), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnSelectedItemChanged))); Telerik has an implementation of this - but I

Using OracleParameter with C# TimeSpan - Literal does not match

我与影子孤独终老i 提交于 2019-12-22 13:58:44
问题 I made an extensive search but I couldn't find any example about this. I have a .NET variable of type TimeSpan and I need to put it into an IntervalDayToSecond record of an Oracle DB. Referring to http://docs.oracle.com/html/B14164_01/featOraCommand.htm this page, it should be possible to pass a TimeSpan object as an OracleParameter and get it inserted into my Oracle DB in a record of IntervalDayToSecond type. This is the code: OracleParameter t = new OracleParameter("PAR_T", _msg.t); I tried

Binding a Combobox control to a separate source within a DataGrid

我们两清 提交于 2019-12-22 11:32:30
问题 Im attempting to use a ComboBox within a DataGrid which will allow the user to select a value coming from a different table. Im using a ViewModel class as the DataContext and this contains an ObservableCollection for Terminals and another for TerminalTypes. The binding on the grid is fine, all the rows are populated and the DataGridTextColumns all show the correct data, my ComboBox however is empty. I know that the ObservableCollection Im attempting to bind to has been populated and if I move

How to create binding inside custom control automatically?

时光毁灭记忆、已成空白 提交于 2019-12-22 11:27:30
问题 I have my custom toolbar control with DependencyProperty IsBusy Here is how I use it: <Controls:myToolbar Grid.ColumnSpan="5" Mode="DataEntry" Status="{Binding State, Converter={StaticResource ViewEditingStateToToolbarStateConverter}}" IsBusy="{Binding IsBusy}"/> By convention all my VM's inherit from base VM and have IsBusy property. So, I KNOW that this property will always be available on VM. Now I have another 4 properties like this. Instead of adding them to XAML on all my views I want

WPF Nested Usercontrol bindings

霸气de小男生 提交于 2019-12-22 10:59:07
问题 I'm trying to bind a value down from a Window into a UserControl inside a UserControl. But, for some reason, the inner UserControl never even attempts to bind as far as I can tell. MainWindow.xaml <Window x:Class="PdfExample.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" xmlns:my="clr-namespace:PdfExample"> <Grid> <my:FileSystemBrowser HorizontalAlignment="Left" x

WPF Image Source binding with StringFormat

拜拜、爱过 提交于 2019-12-22 10:27:04
问题 I'm new to WPF and MVVM (started this week experimenting with it) and trying to bind image resources at runtime. The items I'm trying to display contain an enumerate property that indicates the type or state of the item: public class TraceEvent { /// <summary> /// Gets or sets the type of the event. /// </summary> /// <value>The type of the event.</value> public TraceEventType EventType { get; set; } } As far as I known the Source attribute of Image has a value converter that takes strings

Using INotifyPropertyChanged in WPF

穿精又带淫゛_ 提交于 2019-12-22 10:25:24
问题 Hi i am trying to use the NotifyPropertyChanged to update all the places where i am binding a property. For what i have searched the INotifyPropertyChanged is indicated to this cases. So i need help because i don't understand what i have wrong in here. And i really don't know what to do with the PropertyChange event. My question about that is, when he changes? What i have to more with him? Datagrid: <ListView Name="listView" ItemsSource="{Binding Categories}"/> An example when i change my

Specifying and displaying columns of a DataGrid in WPF declaratively using a binding?

ⅰ亾dé卋堺 提交于 2019-12-22 10:13:27
问题 Is there a way to specify DataGrid columns declaratively using a binding? (And to set the columns' properties using this binding?) Idealy, I would have a list of objects (e.g. rows) databound to the ItemsSource and one of their properties would be a dictionary (or a list of objects of a certain class or whatever) with a name and a value. I would like the DataGrid to automatically create these additional columns without having some code behind. Is that even possible? Or how would you get

JavaFX binding between TextField and a property

你。 提交于 2019-12-22 09:59:33
问题 If you create a binding between a JavaFX TextField and a property, then this binding is invalidated on every keystroke, which causes a change to the text. If you have a chain of bindings the default behavior could cause problems, because in the middle of the editing values may be not valid. Ok, I know I could create an uni-directional binding from the property to the textfield and register a change listener to get informed when the cursor leaves the field and update the property manually if