ComboBox in DataGridTemplateColumn. Binding not working
Tag : chash , By : jonagh
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Binding works with properties, and you declared a public member. You should define your list like this: public List<Brand> BrandList { get;set;}
|
DataGridTemplateColumn binding
Tag : chash , By : fukas78
Date : March 29 2020, 07:55 AM
I hope this helps . Should fix your problem.
|
How to get DataGridTemplateColumn Header Binding working?
Tag : chash , By : Marie Ramos
Date : March 29 2020, 07:55 AM
hop of those help? A Window contains some elements plus a DataGrid. The DataContext of the Window is set to a ViewModel, and the DataGrid is bound to a Property of the ViewModel: , Remember, you bound {Binding} to the proxy's Data property: <wpfUtilities:BindingProxy x:Key="proxy" Data="{Binding}" />
<DataGridTemplateColumn
Header="{Binding Data.TimeColumnHeaderText, Source={StaticResource proxy}}"
Width="Auto"
IsReadOnly="True"
>
|
Binding not working anymore when using TemplateSelector in DataGridTemplateColumn
Tag : chash , By : richardD
Date : March 29 2020, 07:55 AM
I wish this helpful for you Here is my personal solution how to get it working. I have changed the ZlsRouteEditorDataTemplateSelector class with the ability to look for my specific control (ZlsRouteEditor) and get the Mode value. public class ZlsRouteEditorDataTemplateSelector : DataTemplateSelector
{
public DataTemplate ViewDataTemplate { get;set; }
public DataTemplate EditDataTemplate { get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item is ERouteEditor e)
return _GetTemplate(e);
ZlsRouteEditor parent = container.TryFindParent<ZlsRouteEditor>();
if (parent != null)
return _GetTemplate(parent.Mode);
return base.SelectTemplate(item, container);
}
private DataTemplate _GetTemplate(ERouteEditor e)
{
switch (e)
{
case ERouteEditor.View:
return ViewDataTemplate;
case ERouteEditor.Edit:
return EditDataTemplate;
default:
throw new ArgumentOutOfRangeException();
}
}
}
/// <summary>
/// Finds a parent of a given item on the visual tree.
/// </summary>
/// <typeparam name="T">The type of the queried item.</typeparam>
/// <param name="child">A direct or indirect child of the
/// queried item.</param>
/// <returns>The first parent item that matches the submitted
/// type parameter. If not matching item can be found, a null
/// reference is being returned.</returns>
public static T TryFindParent<T>(this DependencyObject child) where T : DependencyObject
{
//get parent item
DependencyObject parentObject = GetParentObject(child);
//we've reached the end of the tree
if (parentObject == null) return null;
//check if the parent matches the type we're looking for
T parent = parentObject as T;
if (parent != null)
{
return parent;
}
else
{
//use recursion to proceed with next level
return TryFindParent<T>(parentObject);
}
}
<DataGridTemplateColumn Header="Station & Programm" Width="*" CellTemplateSelector="{StaticResource StationProgramTemplateSelector}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<recipeControls:ZlsRouteEditor Height="570" Margin="5" Mode="View"/>
<recipeControls:ZlsRouteEditor Height="570" Margin="5" Mode="Edit"/>
</StackPanel>
|
Data binding inside ProgressBar value not working for DataGridTemplateColumn
Date : March 29 2020, 07:55 AM
this one helps. My problem is that I'm trying to display a ProgressBar value inside of a DataGridTemplateColumn, and the binding isn't wanting to work. It will work for my TextBlock (which is in the same Grid), but not the ProgressBar. , It looks like an integer rounding problem here: public int PercentFull { get; set;}
PercentFull = (Convert.ToInt32(c.Quantity) / Convert.ToInt32(data.Capacity) * 100);
public double PercentFull {get; set;}
PercentFull = c.Quantity / Convert.ToDouble(data.Capacity) * 100;
public int PercentFull {get; set;}
PercentFull = Convert.ToInt32(c.Quantity) * 100 / Convert.ToInt32(data.Capacity);
|