WPF如何在后面的代码中设置Gridview绑定中的复选框

Sanjay ranavaya

我必须在代码隐藏中创建的样式。它具有一个如下所示的复选框。

     <GridView>


  <GridViewColumn Width="30">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel>
                                            <CheckBox/>
                                        </StackPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>-->
                            <GridViewColumn  Header="Groups"  DisplayMemberBinding="{Binding Groups}"/>
                           <GridViewColumn Header="SiteTitle" DisplayMemberBinding="{Binding SiteTitle}"/>
                            <GridViewColumn  Header="SiteUrl" DisplayMemberBinding="{Binding SiteUrl}"/>
                        </GridView>

我如何在代码隐藏中工作?

鼠尾草

只需添加此样式Resources并为其x:Name命名。假设给定名称为CustomCheckboxTemplate,则示例代码如下所示:

 DynamicallyCreatedCheckbox.Style = (Style)FindResource("CustomCheckboxTemplate");

希望这可以帮助 :)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在后面的代码中为网格中的复选框分配值

C# WPF 如何在后面的代码中获取绑定值

WPF如何在后面的代码中检索绑定的属性

如何在后面的代码中设置WPF ApplicationCommands

在后面的代码中获取rad网格内每个选中标记的复选框的值

如何在后面的代码中绑定工具提示?

如何在后面的代码中的标签中使用绑定

如何在后面的代码中设置视频标签的来源?

如何在后面的代码中设置框架的高度请求?

如何在后面的代码中设置type =“ password”的文本框的文本

绑定中的WPF StringFormat在后面的代码中不起作用

C# WPF 在后面的代码中绑定到变量和属性

wpf xaml绑定到在后面的代码中创建的对象

如何在后面的代码中生成一个复选框并将其作为子项发送到 MainWindow 的边框?

在后面的代码中设置Xamarin.Forms绑定CommandParameter

在后面的代码中设置AutomationProperties.AutomationId

在后面的代码中设置控件的StaticResource样式

在后面的代码中设置x:DeferLoadStrategy

在后面的代码中设置 RenderFragment 默认内容

WPF 在后面的代码中设置 DataTemplate 网格大小(ResourceDictionary)

如何在后面的代码中设置数据库连接字符串设置

如何处理在后面的代码中引发WPF Validation.ErrorEvent的需要

如何在后面的代码中在Custom DataGrid中的DataGridColumnHeader上附加事件?

如何在后面的代码中访问控件库?

如何在后面的代码中应用materialDesign:ColorZoneAssist.Mode =“ Accent”

如何在后面的代码中编写此XAML故事板?

ASP.NET C#,如何在后面的代码中输入 html

如何在后面的代码中更新隐藏字段的值

如何在 WPF 后面的代码中绑定属性