multibinding

How to use Binding like proxy?

懵懂的女人 提交于 2019-12-20 02:54:07
问题 <Setter Property="IsChecked"> <Setter.Value> <MultiBinding> <!-- Get value for property --> <Binding Path="IsPressed" RelativeSource="{RelativeSource Self}" Mode="OneWay"/> <!-- Set value to ViewModel's property --> <Binding Path="Shift" Mode="OneWayToSource"/> </MultiBinding> </Setter.Value> </Setter> I need to use 2 bindings for property: one to get value for property and one to set value to ViewModel's property. How I can realize this scenario? 回答1: You can create a couple of attached

Generalize guice's robot-legs example with Multibinding

徘徊边缘 提交于 2019-12-18 04:59:07
问题 I have this use case that is very similar to the robot-legs example of Guice, except I don't know how many "legs" I have. Therefore I can't use the annotations needed for the robot-legs example. I expect to gather all these "legs" in an java.util.Set with Guice's Multibindings extension. Technically, in a PrivateModule I would like to expose an implementation directly as an element of the set that will be provided by the Multibindings extension. I just don't know how to do that. For reference

Let WPF Tabcontrol height assume height of largest item?

对着背影说爱祢 提交于 2019-12-17 18:36:13
问题 Is there any way to have to tabcontrol take the size of the largest tab item (well, actually, the tabitem's content)? Since the tabcontrol has no specific size assigned it should autosize: it does that correctly, but when you switch tabs it automatically resizes itself to the height (and width) of the contents of the currently selected tab. I don't want the resizing to happen, and let the tabcontrol assume the height of the largest item, but still have it autosize itself. Any clues? I tried

String format using MultiBinding?

China☆狼群 提交于 2019-12-17 09:22:07
问题 I'm trying to display a string in XAML using Label control. Following is my XAML code : <Label Height="28" HorizontalAlignment="Left" Margin="233,68,0,0" Name="label13" VerticalAlignment="Top"> <Label.Content> <MultiBinding StringFormat="{}{0} x {1}"> <Binding Path="Width" /> <Binding Path="Height" /> </MultiBinding> </Label.Content> Width and Height are two properties of my class Movie. I want the label to display : "Width x Height" ex. 800 x 640 However the label control remains empty. Any

String format using MultiBinding?

亡梦爱人 提交于 2019-12-17 09:21:58
问题 I'm trying to display a string in XAML using Label control. Following is my XAML code : <Label Height="28" HorizontalAlignment="Left" Margin="233,68,0,0" Name="label13" VerticalAlignment="Top"> <Label.Content> <MultiBinding StringFormat="{}{0} x {1}"> <Binding Path="Width" /> <Binding Path="Height" /> </MultiBinding> </Label.Content> Width and Height are two properties of my class Movie. I want the label to display : "Width x Height" ex. 800 x 640 However the label control remains empty. Any

How to bind multiple values to a single WPF TextBlock?

冷暖自知 提交于 2019-12-17 02:04:39
问题 I'm currently using the TextBlock below to bind the value of a property named Name : <TextBlock Text="{Binding Name}" /> Now, I want to bind another property named ID to the same TextBlock . Is it possible to bind two or more values to the same TextBlock ? Can it be done with simple concatenation, like Name + ID and, if not, how else could this be approached? 回答1: You can use a MultiBinding combined with the StringFormat property. Usage would resemble the following: <TextBlock> <TextBlock

Label ContentStringFormat with new line

别等时光非礼了梦想. 提交于 2019-12-14 04:11:40
问题 I try to add new line inside Label ContentStringFormat : Content="{Binding Path=(my:MyData.Files)}" ContentStringFormat="{}Number of files:\n {0:#,0}" Any suggestions ? 回答1: You can't use C# escape characters in XAML code. For XAML there are other possibilities: HEX represenation of CR/LF (or just line feed ): ContentStringFormat="{}Number of files: {0:#,0}" Bind to string that initially contains new line charachters where you need them Use multibinding with Environment.NewLine

Passing two command parameters on button click on WPF NET 3.5 MVVM

倖福魔咒の 提交于 2019-12-13 22:34:34
问题 I am trying to pass two ICommand parameters on button click to a method in view model. Now I am able to pass only one parameter. Code here. XAML (View) : <Button x:Name="btnAdd" Command="{Binding AddUserCommand}" CommandParameter="{Binding IDUser}"/> View Model : public string IDUser { get { return this.personalData.UserID; } set { if (this.personalData.UserID == value) { return; } this.personalData.UserID = value; OnPropertyChanged("UserID"); } } private RelayCommand addUserCommand; public

WPF Multibinding to View Model

风格不统一 提交于 2019-12-13 18:30:30
问题 I am trying to multibind a formatted double value to a text box. I have a converter which takes in a double and a Formatter object and returns a formatted string to be displayed. The double is bound to a particular data source and the formatter is a property in the view model. The problem I'm having is that I'm unable to bind to the view model property. This is my code in xaml <StackPanel Grid.Row="0" Grid.Column="1"> <TextBlock HorizontalAlignment="Left" Style="{StaticResource

Joining 2 collections into datagrid using multibinding

谁都会走 提交于 2019-12-13 16:53:29
问题 I have 2 collections of data, the first one is only for group names and the second one is for values. I want to fill these data in a datagrid like this: groupId | group | store 1 | store 2 | store 3 | store 4 1 | grp 1 | | | | 2 | grp 2 | | | | 3 | grp 3 | | | | 4 | grp 4 | | | | I created a new property in the modelview which creating a new collection of the required rows. Then I tried to achieve it using multibinding and converters like this. <DataGrid> <DataGrid.Columns>