binding

auto binding (type inference) of generic types by the compiler

好久不见. 提交于 2019-12-20 04:45:23
问题 the following code has compilation error in the line of t3: public <E> List<E> getList() { return new ArrayList<E>(); } public <T> void first() { List<T> ret = new ArrayList<T>(); List<T> list = getList(); T t1 = ret.get(0); T t2 = list.get(0); T t3 = getList().get(0); } The error message is: Type mismatch: cannot convert from Object to T I know I can fix the problem using casting or manual binding, my questions is: is it so difficult for the compiler to do auto-binding, is there a case that

Get Text from Datagrid cell or Row

狂风中的少年 提交于 2019-12-20 04:38:14
问题 Hello i am using the data grid to show an observable collection in WPF. Now how can i get the selected row text from the DataGrid so i can call a function. Here is my XAML: <DataGrid x:Name="dataGrid" HorizontalAlignment="Left" Margin="0,77,0,0" VerticalAlignment="Top" Height="720" Width="664" ItemsSource="{Binding Items}" AutoGenerateColumns="False" Grid.ColumnSpan="2" SelectedCellsChanged="dataGrid_SelectedCellsChanged"> <DataGrid.Columns> <DataGridTextColumn Header="ProjectName" MinWidth=

XPath : Bind to last item of collection

风格不统一 提交于 2019-12-20 04:25:06
问题 Can I Bind TextBox.Text to last item of an ObservableCollection<string> ? I tried this: <TextBox Text={Binding XPath="Model/CollectionOfString[last()]"/> But it doesn't bind. Thank you. 回答1: Please try the method following, 1, use IValueConverter. class DataSourceToLastItemConverter : IValueConverter { public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { IEnumerable<object> items = value as IEnumerable<object>; if (items !=

Dynamically Populate ComboBox Within A WPF ListView With Items

折月煮酒 提交于 2019-12-20 04:13:43
问题 I have a WPF ListView which is bound to a data source. In the ListView are dynamically created ComboBoxes, which I would like to bind to another data source to provide the Items, but the SelectedIndex comes from the first data source (see XAML below). Currently, the functionality works fine if the ComboBoxItems are coded statically into the XAML (shown commented out in the XAML below). But, I want to provide the ComboBoxItems (list of strings) dynamically, so I can expand the list, by either

How to programmatically bind a (dependency) property of a control that's inside a DataTemplate?

别等时光非礼了梦想. 提交于 2019-12-20 04:12:23
问题 The TextBlock resides in a DataTemplate , thus I can't refer to it by its name. So how do I bind its (e.g.) Text property programmatically? XAML: <UserControl x:Class="MyNameSpace.MyCustomControl" ... > ... <ListBox ItemsSource="{Binding Path=ItemsSource}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> ... </UserControl> Code: public partial class MyCustomControl : UserControl { ...

In Objective-C, does the binding of method really happen at “run-time”?

给你一囗甜甜゛ 提交于 2019-12-20 03:57:07
问题 I heard that Objective-C is influenced by the "message passing mechanism" of SmallTalk. Objective-C, like Smalltalk, can use dynamic typing: an object can be sent a message that is not specified in its interface. This can allow for increased flexibility, as it allows an object to "capture" a message and send the message to a different object that can respond to the message appropriately, or likewise send the message on to another object. And I felt for codes like [anObject someMethod] , the

Binding the Width Property of a DataGridColumn to the ActualWidth of the parent DataGrid

有些话、适合烂在心里 提交于 2019-12-20 03:46:12
问题 I tried to solve my previous question with manually binding the Width property of the DataGridTextColumn here is the first Version of my XAML Code. <DataGrid AutoGenerateColumns="False" Background="White" ItemsSource="{Binding Items, Mode=OneWay}" HorizontalGridLinesBrush="Silver" VerticalGridLinesBrush="Silver" Margin="332,10,10,10" CanUserAddRows="False" CanUserDeleteRows="False" x:Name="myDataGrid" ColumnWidth="*"> <DataGrid.Columns> <DataGridTextColumn Width="{Binding Path=ActualWidth,

javafx Bindings.createStringBinding but binding not actually work

本秂侑毒 提交于 2019-12-20 03:26:04
问题 I'm trying to bind the textProperty of the Label to the object's SimpleIntegerProperty with help of Bindings but it does not change the text when I change the SimpleIntegerProperty of the object in real time. Any help would be appreciated of how to make textProperty change. package sample; import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleIntegerProperty; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Label; import javafx.scene

WPF Image Visibility Binding in XAML

大城市里の小女人 提交于 2019-12-20 03:18:35
问题 I’ve got a little problem binding an image to a Radiobuttion. I only want to bind it via XAML an what I did is this.. I createad a Stackpanel with 5 radiobutton in it.. <StackPanel Name="StackPanel1" Grid.Row="3" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center"> <RadioButton GroupName="Group1" Content="1" HorizontalAlignment="Left" Width="35" BorderThickness="1,0,0,1" IsChecked="CodeBehindBinding..." /> <RadioButton GroupName="Group1" Content="2" HorizontalAlignment="Left"

Style triggers in Windows Phone 7

别等时光非礼了梦想. 提交于 2019-12-20 02:59:24
问题 I want to use the style triggers in Windows Phone 7 to change the source of an image depending a boolean variable. I Wann do something like this : <Image Source="/Century21;component/Images/appbar.favs.addto.rest.png" Name="IconButtonSelection"> <Image.Style> <Style TargetType="Image"> <Setter Property="Source" Value="/Century21;component/Images/appbar.favs.addto.rest.png"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding IsSelected}" Value="True"> <Setter Property="Source" Value="