0
我有一列在我的datagrid包含圖標。 爲此我有一個單元模板以編程方式添加到列。設置圖標高度圖像模板編程
var imageFactory = new FrameworkElementFactory(typeof(System.Windows.Controls.Image));
imageFactory.SetBinding(System.Windows.Controls.Image.SourceProperty, imageBinding);
imageFactory.SetValue(System.Windows.Controls.Image.StretchProperty, Stretch.None);
if (config.Font != null)
{
double height = config.Font.Size;
imageFactory.SetValue(FrameworkElement.HeightProperty, height);
}
var dataTemplate = new DataTemplate { VisualTree = imageFactory };
statusColumn.CellTemplate = dataTemplate;
view.DataGrid.Columns.Add(statusColumn);
當我設置高度屬性外部它作物而不是調整大小圖像「高度」值的圖像。
如何將圖像高度設置爲特定值。請提出 。
我已經嘗試過上面的設置HeightPrtoperty。但仍然不起作用 – deathrace 2013-03-19 09:10:06
實際上,我的問題是圖標圖像將在執行期間隨時加載。所以我現在只是在加載時有FrameworkElementFactory。現在,我試圖setimageFactory.SetValue(FrameworkElement.HeightProperty,height);但它不起作用。它動態地裁剪圖像圖標。 – deathrace 2013-03-19 12:24:55