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

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

帶有 RibbonComboBox 的 WPF 綁定警告

帶有 RibbonComboBox 的 WPF 綁定警告

C#
30秒到達戰場 2023-04-29 10:01:56
我正在嘗試學習和理解 c# 中的功能區控件,尤其是數據綁定,但在實現 RibbonComboBox 時收到許多我無法解決的警告。我已設法刪除錯誤消息,但警告仍然存在。我該如何解決?相關文件如下所示,我刪除了無關信息以簡化它們。這是 XAML 文件 - MainWindow.xaml:<RibbonWindow x:Class="MyProject.MainWindow"        ...        xmlns:local="clr-namespace:MyProject"        xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"        mc:Ignorable="d"        Title="MyProject" Height="450" Width="800" x:Name="MyProjectControl" >    <Grid>        <Ribbon DockPanel.Dock="Top" x:Name="Ribbon">            <RibbonTab Header="Home" >                <RibbonGroup Header="Shapes" Width="160">                    <RibbonComboBox x:Name="cbShape" Height="Auto" Width="Auto" Label="Shape" VerticalAlignment="Center">                        <RibbonGallery x:Name="shapeComboBox" SelectedItem="{Binding Path=Shape, UpdateSourceTrigger=PropertyChanged, Mode=OneWay, diag:PresentationTraceSources.TraceLevel=High}" >                            <RibbonGalleryCategory x:Name="shapeList" ItemsSource="{Binding Path=Shape, Mode=OneWay}" />                        </RibbonGallery>                    </RibbonComboBox>                </RibbonGroup>            </RibbonTab>        </Ribbon>    </Grid></RibbonWindow>它背后的代碼 - MainWindow.xaml.cs:using System.Collections.Generic;using System.Windows.Controls.Ribbon;namespace MyProject{    public partial class MainWindow : RibbonWindow    {        public MainWindow()        {            InitializeComponent();            InitializeLists();            this.DataContext = new RibbonSettings();        }        private void InitializeLists()        {            List<string> MyShapes = new List<string>            {                "Square", "Circle", "Ellipse", "Triangle", "Pentagon"            };            shapeList.ItemsSource = MyShapes;        }    }}
查看完整描述

1 回答

?
SMILET

TA貢獻1796條經驗 獲得超4個贊

您所指的警告只是擴展的跟蹤信息。只要綁定按照您的預期工作,就沒有必要檢查它們。但是,如果您在輸出中看到System.Windows.Data 錯誤,則意味著您需要注意它的內容(在我的例子中,最常見的原因是屬性名稱中的拼寫錯誤)。

您可以通過更改WPF Trace Settings下的Data Binding設置,在 Options -> Debugging ->?

查看完整回答
反對 回復 2023-04-29
  • 1 回答
  • 0 關注
  • 170 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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