gpt4 book ai didi

c# - 如何更改 Xamarin Studio 中 GUI 设计器生成的字段的访问级别

转载 作者:太空宇宙 更新时间:2023-11-03 23:40:00 25 4
gpt4 key购买 nike

我正在使用 Xamarin Studio 在 Gtk# 中编写我的代码。当我在其中创建一个新窗口和一个 TreeView 时,访问级别将是私有(private)的。我想在其他类中使用它 (TreeView),所以我想将访问级别更改为内部,但我找不到如何做到这一点。感谢您提前提供帮助。这是我想由 GUI 设计者更改的代码(不是写入代码内部,因为它会被 GUI 设计者覆盖...)

    // This file has been generated by the GUI designer. Do not modify.
namespace XX_xxxx
{
public partial class Settings
{
private global::Gtk.VBox vbox1;

private global::Gtk.ScrolledWindow GtkScrolledWindow;

private global::Gtk.TreeView settingsTreeView;

private global::Gtk.HBox hbox1;

private global::Gtk.ToggleButton saveAndCloseButton;

private global::Gtk.ToggleButton closeButton;

protected virtual void Build ()
{

这是我想使用的地方(在我使用 Settings 类实例的其他类中):settings.settingsTreeView.Model = settingsListStore;

错误信息是:

Error CS0122: `XX_xxxxx.Settings.settingsTreeView' is inaccessible 
due to its protection level (CS0122) (XX_xxxx_GUI)

最佳答案

我在 Xamarin 论坛上得到了这个答案:

The supported way of doing this is to remove the property from the .designer.cs file and place it in the main .cs file. Then remove the [DesignerGenerated] attribute from the declaration.

The code generation in the designer will recognise that the [Outlet] exists in the actual .cs file and will not place one in the .designer.cs file. Once you do this, you can add the public/internal modifiers as you want.

关于c# - 如何更改 Xamarin Studio 中 GUI 设计器生成的字段的访问级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29369760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com