Quantcast
Viewing all articles
Browse latest Browse all 18858

Can iset a Binding inside a FrameworkElementFactory to an AttachedProperty??

hey

i've written following:

//This is the class with my AttachedProperty!!!!

namespace Classes
{
class AttachedProperties
{

public static readonly DependencyProperty TabItemFontSizeAttachedAP = DependencyProperty.RegisterAttached("TabItemFontSize", typeof(double), typeof(AttachedProperties));

public static void SetTabItemFontSize(UIElement element, double value)
{
  element.SetValue(TabItemFontSizeAttachedAP, value);
}

public static double GetTabItemFontSize(UIElement element)
{
return (double)element.GetValue(TabItemFontSizeAttachedAP);
}


}
}

//So i set the AttachedProperty to a TabItem and make a call for Template!!

TabItem item = tabitem;
item.SetValue(Classes.AttachedProperties.TabItemIconSizeAttachedAP, 15.0);  <--- Here is set the Attached Value!!!!!!!!!!!!!!!!
DataGrid datagrid = item.Content as DataGrid;
DataGridTemplateColumn templatecolumn = new DataGridTemplateColumn();
templatecolumn.CellTemplate = GetTemplate(item); //<--Call!
datagrid.Columns.Add(templatecolumn);

//And now the Template with the Binding:

DataTemplate GetTemplate(TabItem item)
{
DataTemplate FileNameColumnDataTemplate_GV = new DataTemplate();
 .... 
 ....         
imagefactory.SetBinding(Image.WidthProperty, new Binding("Classes.AttachedProperties.TabItemIconSizeAttachedAP") { Source = item});<------- Here is the Binding, that doesn't work!!!!!!!!!!!
....
....           
return FileNameColumnDataTemplate_GV;
}
I've tried every way of Notation (used ElementName innstead of source) etc., but nothing worked. I aslo read the articlehttp://social.msdn.microsoft.com/Forums/en-US/28c2d241-2a23-4977-b23d-60f265a59bfc/can-is-set-a-binding-inside-a-frameworkelementfactory-to-an-attachedproperty-of-another-object?forum=wpf

but nothing useful. So my question, how this kind of binding can work??

   


    {


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>