datatemplate

Binding ZIndex from DataTemplate

你离开我真会死。 提交于 2020-08-25 03:51:45
问题 I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl ItemsSource="{Binding MyItems}" ItemTemplate="{Binding Source={StaticResource MyItemsDataTemplate}}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </Grid> </ViewBox> </Grid> The DataTemplate used here can be reduced to this: <DataTemplate x:Key="AreaItemDisplayDataTemplate"> <Canvas Grid.ZIndex={Binding Z}> <Grid> // an shape is

Specify a default empty DataTemplate instead of the default 'ToString()' DataTemplate

戏子无情 提交于 2020-06-25 08:07:32
问题 The default DataTemplate in a wpf application displays the result of the .ToString() method. I'm developing an application where the default DataTemplate should display nothing. I've tried: <Grid.Resources> <DataTemplate DataType="{x:Type System:Object}"> <Grid></Grid> </DataTemplate> </Grid.Resources> But this doesn't work. Does anyone knows if this is possible without specifiing a specific DataTemplate for every class type in the application? 回答1: I know of no way to do this. As per Joe's

ListView ignoring DataTemplates when using a ControlTemplate

守給你的承諾、 提交于 2020-06-23 09:33:42
问题 I try to implement a multi column ListView. Everything worked just fine until I tried to style the mouseover- and selection-look of the list view items. I therefore created a ControlTemplate (see XAML below). When I use the ControlTemplate, the DataTemplates for the columns are ignored. When I remove the ControlTemplate everything is fine again. Can someone point me to the error? Thanks! <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Style.Resources>

ListView ignoring DataTemplates when using a ControlTemplate

谁说我不能喝 提交于 2020-06-23 09:33:27
问题 I try to implement a multi column ListView. Everything worked just fine until I tried to style the mouseover- and selection-look of the list view items. I therefore created a ControlTemplate (see XAML below). When I use the ControlTemplate, the DataTemplates for the columns are ignored. When I remove the ControlTemplate everything is fine again. Can someone point me to the error? Thanks! <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Style.Resources>

ListView ignoring DataTemplates when using a ControlTemplate

谁说我不能喝 提交于 2020-06-23 09:33:05
问题 I try to implement a multi column ListView. Everything worked just fine until I tried to style the mouseover- and selection-look of the list view items. I therefore created a ControlTemplate (see XAML below). When I use the ControlTemplate, the DataTemplates for the columns are ignored. When I remove the ControlTemplate everything is fine again. Can someone point me to the error? Thanks! <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Style.Resources>

TextBox inside a ListView bound to an object, two way binding dosen't work

这一生的挚爱 提交于 2020-05-29 09:46:17
问题 Edit: Ok after finally playing around numerous times without no luck, I have created a very small Wpf application. You can directly copy this code. Notice when you change values in the TextBox and press the Test button, the values never get updated. I don't understand why the two way binding dosen't work. Please help. Here is the xaml: <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <ListView Grid.Row="0" ItemsSource="{Binding

WPF - Parameters to DataTemplates?

我与影子孤独终老i 提交于 2020-05-12 11:52:52
问题 I have a ListBox showing data about employees such as name, department photo, badge number, etc. Employees may have different types such as Manager, Staff, Volunteers. I have 3 separate data templates - one for each type. All of these templates show basically the same data but presented differently. Depending on the user logged into the application pictures, Badge Number, etc, can or cannot be visible. So I have boolean properties for that - CanSeePhotos, CanSeeBadgeNumbers, etc. So if

UWP XAML add data binding outside datatemplate

丶灬走出姿态 提交于 2020-02-07 02:36:23
问题 I'm trying to add button to this datatemplate but I cannot access the ICommand EditTripClick Command from the ViewModel. So I am wondering is it possible to access it although I am in a datatemplate? Example code of what I want to do <CommandBar OverflowButtonVisibility="Auto"> <AppBarButton Label="Add trip" Icon="Add" Command="{x:Bind ViewModel.NewTripClickCommand}"/> <AppBarButton Label="Refresh" Icon="Refresh" Command="{x:Bind ViewModel.RefreshClickCommand}"/> </CommandBar> <controls

Binding a WPF Button CommandParameter to the Button itself in DataTemplate

做~自己de王妃 提交于 2020-01-29 06:38:26
问题 I have a DataTemplate that represents AppBar buttons that I declare through a collection of custom AppBarCommand objects. public AppBarCommand(RelayCommand command, string buttonstyle) { Command = command; ButtonStyle = buttonstyle; } <DataTemplate> <Button Command="{Binding Command}" Style="{Binding ButtonStyle, Converter={StaticResource StringNameToStyleConverter}}"/> </DataTemplate> I would like to add a CommandParameter binding, but the parameter has to be the Button itself. This is so I

Binding a WPF Button CommandParameter to the Button itself in DataTemplate

為{幸葍}努か 提交于 2020-01-29 06:38:05
问题 I have a DataTemplate that represents AppBar buttons that I declare through a collection of custom AppBarCommand objects. public AppBarCommand(RelayCommand command, string buttonstyle) { Command = command; ButtonStyle = buttonstyle; } <DataTemplate> <Button Command="{Binding Command}" Style="{Binding ButtonStyle, Converter={StaticResource StringNameToStyleConverter}}"/> </DataTemplate> I would like to add a CommandParameter binding, but the parameter has to be the Button itself. This is so I