亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

GridViewColumn CellTemplate c#的WPF動態變化

GridViewColumn CellTemplate c#的WPF動態變化

C#
呼如林 2021-10-24 19:50:49
我正在嘗試了解有關 ListView 的知識,現在我正在解決這個問題:我在后臺代碼中定義了一個列表視圖。我想動態更改 gridviewcolumn celltemplate。例如通過使用復選框或按鈕,或其他。甚至有可能嗎?我的 ListView 的定義在這里:        lvUsers.ItemsSource = LoadListViewData();        GridView gridview = new GridView();        lvUsers.View = gridview;        DataTemplate templateCheck = new DataTemplate();        FrameworkElementFactory factoryContentControlCheck = new FrameworkElementFactory(typeof(VsCheckBox));        factoryContentControlCheck.SetValue(VsCheckBox.MarginProperty, new Thickness(0, 0, 0, 0));        DataTemplate templateBorder = new DataTemplate();        FrameworkElementFactory factoryContentControlBorder = new FrameworkElementFactory(typeof(Border));        factoryContentControlBorder.SetValue(Border.MarginProperty, new Thickness(0, 0, 10, 0));        factoryContentControlBorder.SetValue(Border.WidthProperty, Width = 10);        factoryContentControlBorder.SetValue(Border.HeightProperty, Height = 10);        factoryContentControlBorder.SetValue(Border.BackgroundProperty, Brushes.Red);                    DataTemplate templateAge = new DataTemplate();        FrameworkElementFactory factoryContentControlAge = new FrameworkElementFactory(typeof(ContentControl));        factoryContentControlName.SetValue(ContentControl.MarginProperty, new Thickness(0, 0, 10, 0));        factoryContentControlAge.SetValue(ContentControl.VerticalAlignmentProperty, VerticalAlignment.Center);        factoryContentControlAge.SetValue(ContentControl.HorizontalAlignmentProperty, HorizontalAlignment.Right);        factoryContentControlAge.SetBinding(ContentControl.ContentProperty, new Binding("Age"));我想在運行時通過選中復選框或按鈕單擊將 colStack 的 CellTemplate 更改為 templateStack1。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 431 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號