Questions tagged [datatemplate]

Data templating is a feature of WPF and Xamarin.Forms that lets you customize the presentation of data.

Filter by
Sorted by
Tagged with
1 vote
1 answer
48 views

WPF put ListView items DataTemplate to a separate file

I have a simple task, but a little bit confused with it. So, I have a ListView on some of my windows and I have a custom ListView item that I put in the separate file calls "ListViewItem.xaml&...
whizzzkey's user avatar
  • 926
1 vote
1 answer
98 views

MAUI event to command behavior command binding to viewmodel

So i got ContentPage.Resources in which i define DataTemplate for BindableLayout. I need to bind Unfocused editor event from this DataTemplate to my ViewModel relay command. But i cant just do it like ...
Death_Dealer's user avatar
0 votes
1 answer
40 views

WPF Adding StatusBarItem using mvvm and Datatemplate

I'm trying to add StatusBarItem dynamically by using mvvm pattern but i don't know what to do. If i write the code that i want to create in XAML file, it looks like this: <StatusBar Grid.Row="...
user530530's user avatar
0 votes
1 answer
128 views

Accessing Controls of a DataTemplate with underlying ContentView hosting the Controls?

I use a SharpNado CollectionView in .NET MAUI with a DataTemplate as can be seen below. There is also a Button which has its Button_Clicked-Event in the Code-Behind file. From there, I wanted to ...
OXO's user avatar
  • 143
0 votes
1 answer
51 views

Change Styling for WinUI3 TreeView Items On State

I am trying to get a TreeView to look kind of "grayed out" and disable the use of it on a boolean being true. The issue I am having is the current layout of the XAML seems to be preventing ...
jhkrum's user avatar
  • 3
0 votes
2 answers
33 views

How to get AccessKey to work with DataTemplate in NavigationView

I am using WinUI 3 and WindowsAppSDK. When I use a NavigationView and set AccessKey on the NavigationViewItem, it works ... until I also define the MenuItemTemplate. As soon as a DataTemplate is used ...
sjb-sjb's user avatar
  • 1,112
0 votes
0 answers
26 views

WPF Textbox TwoWay binding in datatemplate not updating the source [duplicate]

I created a ListBox in which I specified a DataTemplate with a Grid and two elements in it (TextBlock and TextBox). The source in ListBox is ObservableCollection<int>. Everything displays fine, ...
I_Mimic_I's user avatar
0 votes
1 answer
43 views

WinUI 3 ListView Linked To Observablecollection contains layer classes derived from class canvas

I want to create an application like photoshop main canvas which groups layer canvases, a listview which displays the name of the layers and a visibility button via a datatemplate of each layer added ...
mustapha chaibi's user avatar
-1 votes
2 answers
99 views

WinUI 3 ListView Linked To Observablecollection contains Canvases

I am developing a WinUI 3 application which contains a ListView linked to an Observablecollection which contains canvases , the listview displays the names of the canvases via a DataTemplate but the ...
mustapha chaibi's user avatar
0 votes
2 answers
42 views

CustomColumn and Binding

I have DataGrid with ObservableCollection of My class type as DataSource. I'm using a few TemplateColumns with the same DataTemplate so i got an idea that I create class for that column. The problem ...
hubert kwiecień's user avatar
0 votes
1 answer
137 views

WPF Drawing a list of rectangles in a collection

My WPF app has a ViewModel that has an ObservableCollection that holds objects of type Item. Each Item has a color and a Rect that is drawn on the canvas: Item Class: public class Item { public ...
dransom90's user avatar
  • 1,600
0 votes
2 answers
249 views

MAUI RadioButton with ControlTemplate and DataTemplate doesn't render content

I am trying to create RadioButtons that bind to a list of content using a DataTemplate, and render based on a ControlTemplate. The data binding is working - I get a button for each element in the ...
Chuck's user avatar
  • 55
-2 votes
1 answer
219 views

Maui: Change gridView template conditionally

I have a grid inside a CollectionView and I need to change the layout based on a certain condition, changing dynamically the size of the columns and rows and hiding/showing some specific columns. The ...
Innova's user avatar
  • 324
0 votes
1 answer
162 views

When using CollectionView and DataTemplate, how can I display/Use the index/position of my item?

I want a CollectionView with at least 2 labels 1st label is for indexOf the object 2nd label is for a property (name) as this is a CustomView I only have access to Enumerable ItemsSource. But not the ...
zxcAsk's user avatar
  • 11
-1 votes
1 answer
567 views

Add Button in DataTemplate in CollectionView .netMaui

I want to add a Button in my CollectionView for each Item. I work with MVVM and want also pass the CommandParameter of the Item. My idea solution is this one: <CollectionView.ItemTemplate> ...
Tobination's user avatar
0 votes
0 answers
53 views

How exactly does binding work for list of ViewModels in ReactiveUI

I am currently learning ReactiveUI for WPF. I have rebuilt the following example project and tried to understand it: https://www.reactiveui.net/docs/getting-started/compelling-example I could ...
dba12's user avatar
  • 1
0 votes
0 answers
40 views

Refreshing a DataGrid within a datatemplate in order to update the bindings

The properties in the (below) DataGrid are not Observable so they do not get updated in the view automatically. Keeping them as not observable is intentional. The underlying model data does get ...
neo's user avatar
  • 65
0 votes
1 answer
34 views

Change the Fill Color of a path displayed in a DataGrid column

I have a DataGrid, that shows a Path in the second column. This path is different based on the value in the bound property. If I select the row, the Stroke color almost disapears in the background ...
Herbert Nijkamp's user avatar
1 vote
2 answers
231 views

How to use x:Bind in a DataTemplate for a ToggleSwith.HeaderTemplate in WinUI 3

I'm trying to create a simple Style for the Header of all the ToggleSwitches on a given Page (WinUI 3 v1.2 desktop project). I'd really like to use x:Bind for all of my bindings (not Binding). Here's ...
aturnbul's user avatar
  • 327
0 votes
1 answer
51 views

Display only one TextBox which is bound to selected item from ListView

I have a ListView which is bound to an ObservableCollection I have added a DataTemplate to a ListView to bind item with TextBox in purpose to Rename selectedItem using Rename from ContextMenu: View ...
PanJakub97's user avatar
0 votes
1 answer
28 views

How to reference Checkbox which is defined in DataTemplate

I have a datagrid as below. I want to reference CheckBox which is named ckbSelectedAll in code behind. WPF does not allow to reference with the name in code behind. Which way should i follow ? <...
şahin's user avatar
  • 7
0 votes
1 answer
23 views

dynamic adjustment of the environment in DataTemplates through (Visible/Invisible)-property

The problem is that if you include a DataTemplate from ContentPage.Resources from CollectionView with ItemTemplate and make fields visible or invisible in it, then the environment does not adapt to ...
Marcel Fischer's user avatar
0 votes
1 answer
126 views

How do I bind Resource Properties in a datatemplate?

I want to create an app for a game and decided I'd use winui3 for it as it seems to be the closest looking for what I've been searching for. So I'm quite new to this sort of stuff. Now to my Question: ...
Ayes's user avatar
  • 15
1 vote
1 answer
169 views

Selecting a data template based on type in UWP

Given these types public class TestTypeBase { public string Name { get; set; } } public class TestTypeToggle : TestTypeBase { } public class TestType : TestTypeBase { public bool Enabled { get;...
ridilculous's user avatar
0 votes
1 answer
86 views

Binding a button nested in DataTemplate

I need to bind a button's command inside a datatemplate like below: <GridViewColumn.CellTemplate> <DataTemplate> ...
Giusek keisuG's user avatar
-1 votes
2 answers
56 views

Set Binding of Element inside Datatemplate

I am building a DataGrid with DataGridTemplateColumns. The CellTemplate is created as DataTemplate in XAML: <DataTemplate x:Key="StringCell"> <Grid DataContext="{Binding ...
otto.kranz's user avatar
-2 votes
2 answers
55 views

Datatemplate binding itemsource inside Datatemplate

I want to bind a ObservableCollection to a Itemscontrol inside a Datatemplate, that is inside another Datatemplate: <ListView x:Name="list_befehlsfolge" Margin="5"> <...
user3600403's user avatar
0 votes
0 answers
65 views

Loading Image into WPF DataGrid Via Convert Method

Little rusty here. I'm trying to display a image in a WPF Gridview. Below is the XAML for the template column. The converter is also below, which is calling and finding the image and returning the ...
M.Powell's user avatar
-1 votes
2 answers
195 views

How binding the ToolTip property from within the DataTemplate to the property of the parent UserControl?

How binding user control dependecy property? I want ToolTip dependency property IsEnabled to bind from UserControl dependency property IsShowToolTip. I try RelativeSource, but this can't find source. ...
Jarosław Pietras's user avatar
1 vote
2 answers
2k views

Dotnet MAUI with MVMM - Dynamic dataTemplate based on ObservableCollection<T> where T is an interface

I'm trying de build a new DotNet MAUI application. I have a datasource of this kind : public ObservableCollection<IIpxElement> IpxElements { get; } With this in the Xaml <CollectionView ...
CyrilJ's user avatar
  • 49
1 vote
1 answer
40 views

UWP use a datatemplate inside a datatemplate

Lets say I have class A, and B, which B : A. Now Lets say I have a datatemplate for class A: Atemplate, and now I want to create a datatemplate for class B : Btemplate which will use Atemplate and ...
Guy Madmon's user avatar
0 votes
1 answer
68 views

Is there a way to inject an Item/DataTemplate into a custom Style or UserControl?

Read update for a solution I have a small WPF Application with several small game clones such as Minesweeper, Connect 4, Tic Tac Toe among others. Common for all of these is that they are all a ...
Silop's user avatar
  • 5
0 votes
0 answers
68 views

WPF- TabControl. how to get DataTemplate key

I have created a TabControl whose tabs are bound to UserControls <Window x:Class="_MainWindow"...> .... <TabControl ItemContainerStyle="{StaticResource TabItemStyleVM}...
calacausi's user avatar
-2 votes
2 answers
51 views

Select view depending on screen resolution

I have a WPF application made for an LCD display with a specific resolution. The WPF application is fixed size. The view is bound to its view model by DataTemplates like this: <DataTemplate ...
Rene's user avatar
  • 516
0 votes
1 answer
88 views

ListView in WinUI maintains ListBox text after reset

I have a ListView in a WinUI 3 app (target framework net6.0-windows10.0.19041.0) with a data template that contains a TextBox. The ItemsSource is bound to an ObservableCollection in the code-behind ...
Gabriel S.'s user avatar
  • 1,347
0 votes
0 answers
32 views

Why is my RelayCommand not executing when clicking on my DataTemplate established button

Here is my code, the problem I am facing is that the the RelayCommand isn't really executing my MessageBox.Show(title.ToString()), but when I do MessageBox.Show("hello"), it works perfectly ...
user24652070's user avatar
0 votes
1 answer
141 views

ComboBox crashing with custom ItemTemplate

I'm writing a WinUI 3 app and am making a dialog in which the user can select one of multiple object types. For the ComboBox's ItemTemplate I'm using a TextBlock whose Text is bound to the Name ...
Crumbler's user avatar
0 votes
1 answer
215 views

Control template triggers cannot set value when used with StaticResource or x:Static

Strange issues I faced. When trying to use StaticResource or x:Static with a converter from ControlTemplate.Trigger the converter value is always NULL. In the below example the different usages are ...
Nawed Nabi Zada's user avatar
0 votes
1 answer
65 views

Need direction for best way to minimize data template code in Xamarin form

In MVC ASP.net Core, I used partials to re-use blocks of a page. In Xamarin, we have DataTemplates & ControlTemplates but I'm not sure how to best use them. In one of my pages I have the ...
Lution's user avatar
  • 65
0 votes
0 answers
60 views

using a datatemplate on Polylines

i try to Bind a X and Y out of Observablecolletion.Points directly with Datatemplate. Reason is I want to use converter on X and Y later on. I did the Binding like this. <ItemsControl ItemsSource=&...
CarlPotato's user avatar
0 votes
1 answer
101 views

Xamarin list of RadioBox set GroupName from view model

All the examples for RadioButtons I've found so far have the values hard-coded in the xaml for the page. I'm looking to feed a list of strings (for now) from a database and running into an issue with ...
Lution's user avatar
  • 65
0 votes
1 answer
42 views

How to Get SelectedItem as DataTemplate in Listview?

I have a listview Which is defined as follows: <DataTemplate x:Name="myTemplate" x:DataType="table:myItem"> <RichTextBlock Margin="10" IsTextSelectionEnabled=&...
karma's user avatar
  • 137
2 votes
2 answers
1k views

How to create DataTemplate with code? [MAUI]

How to create a DataTemplate with code? DataTemplate does not have a VisualTree property like in WPF. The docu doesn't help either. There is an IDataTemplateController, but it does not control ...
Kux's user avatar
  • 1,262
0 votes
2 answers
61 views

How is it possible to set the focus on the last item of a DataTemplate?

How is it possible to set the focus (from c#-code behind or xaml itself) to the last item of my DataTemplate? That is my XAML code: <ItemsControl x:Name="ListViewItems"> <...
Florian's user avatar
  • 851
0 votes
0 answers
171 views

Binding to ItemsSource and SelectedItem of a ComboBox with custom Style (WPF .NET Core MVVM)

I am trying to bind the ItemsSource and SelectedItem properties of a ComboBox and the items are not displaying properly. The ComboBox is populated with the values of an Enum based on a solution ...
Florin Zamfir's user avatar
0 votes
1 answer
100 views

How to find a DataTemplate control from inside the Click event

I have a GridView with a ColumnHeaderTemplate The template contains a path with the name arrow: <DataTemplate x:Key="HeaderTemplate"> <DockPanel> <Path DockPanel.Dock=&...
Paul Spain's user avatar
0 votes
1 answer
443 views

How to binding different data context to data template?

I try to simplify my Main user control that contains 8 user controls that are exactly the same but they are binding to different VM to display its data. Currently, I have to create a template for each ...
Thich Coi Phim's user avatar
0 votes
1 answer
147 views

Powershell XAML - Use XAML datatemplate to create new tabitems

I have a small XAML form and i run it from within a powerShell script. It has a controltemplate called "newTab" which I use to create a tab with two buttons. Inside the XAML that works fine. ...
Dom's user avatar
  • 157
0 votes
1 answer
86 views

How to change a property of a specific element in a DataTemplate from code behind?

I have a bug in my code. FindChild<T>() is searching a Element which is named "PasswordTextBox" but because "PasswordTextBox" is in the DataTemplate there are many TextBoxes. ...
Florian's user avatar
  • 851
1 vote
1 answer
166 views

WPF MVVM: Datagrid Template ToggleButton not communicating with Model when clicked

This is my first question on here so bear with me. I am stumped on why this ToggleButton column doesnt communicate changes to the Match model Reviewed property when toggled: <ToggleButton ...
Kyle7286's user avatar

1
2 3 4 5
50