[英]Cannot bind slider value in DataGridTemplateColumn
我正在嘗試創建一個包含兩個文本列和一個模板列的 DataGrid,如下所示:<UserControl ... Name="TcpNtcpSliders" ...> <DataGrid Name="MinTcpDataGrid" AutoGenerateColumn ...
[英]Cannot bind slider value in DataGridTemplateColumn
我正在嘗試創建一個包含兩個文本列和一個模板列的 DataGrid,如下所示:<UserControl ... Name="TcpNtcpSliders" ...> <DataGrid Name="MinTcpDataGrid" AutoGenerateColumn ...
[英]Nested UserControl(s) throw "Property was already registered by"
我有這個用戶控件 xaml: 及其背后的代碼,我定義了一個 DependencyProperty 來編輯線條顏色: 然后我有另一個 UserControl,里面有 SeparatorLineText: 最后,在 MainWindow.xaml 中,我包含了 MySubWindow,其中包含 Sep ...
[英]Best practice for dependency properties with reference type as default value
我有以下 DependencyProperty: 現在你可以看到給它一個引用類型作為默認值只會工作一次,只要我創建這個 class 的第二個實例,他們就會共享該引用。 我找不到太多關於它的信息,最好的方法是什么,有人有建議嗎? 一種方法是不給它默認值並在構造函數中使用新實例設置引用: ...
[英]View model property bound to a dependency property from another user control is never called every time the dependency property is set to true
我有一個 WPF 用戶控件,我在其中放置了另一個 WPF 用戶控件。 注意,我這里只貼出相關的東西,方便大家理解。 此處您必須注意的重要事項是視圖模型屬性 IsHyperlinkChangedCallback,它綁定到 myAnotherUserControl 用戶控件的依賴屬性(同名)。 這被設置 ...
[英]Using named in reusable WPF control
我最近在 WPF 中發現了“可重復使用的控件”,我有一個項目,它們似乎為我提供了解決我遇到的問題的方法。 讓我描述一下情況:我需要制作幾個 UI 元素。 它們都共享一個共同的基礎,可以說是一個共同的樣式/布局/模板,並且它們還共享一些共同的邏輯。 除此之外,所有這些元素都有一些特定於元素的東西。 ...
[英]Why is the root element of MainWindow Window instead of MainWindow?
我注意到任何 XAML 文件(在 WPF 中)中的根元素似乎是以下之一: Window Page UserControl ResourceDictionary Application 我試圖將根元素更改為local:MainWindow ,但是項目無法編譯,說部分 class 的基數 class ...
[英]WPF - Properties of ItemsSource to Dependency Properties
背景我正在制作一個具有多個 ListBox 的自定義控件。 我想讓這個控件符合 MVVM,所以我保留了任何 XAML 以及與任何 ViewModel 無關的代碼。 一個 ListBox 只是一個 TextBox 的列表,而另一個將有一個 canvas 作為主機以圖形方式顯示數據。 這兩個 ListB ...
[英]How to bind dependency property to DataGridComboBoxColumn in UserControl?
我的用戶控件的 XAML 名稱為“Clinical_Protocol”: 后面代碼中DataGrid的ItemsSource的依賴屬性:internal ObservableCollection<ClinicalProtocolDataGridItem> DataGridItems { ...
[英]Dependency property for ItemsSource column to set DataTrigger condition
我如何通過控件(Datagrid)的依賴屬性正確綁定到 ItemsSource 列,以設置它的 DataTrigger 工作? 我的目標沒有依賴屬性:<Style TargetType="DataGridRow"> <Style.Triggers> < ...
[英]How to bind dependency property of ICommand of ItemsControl member to parent view model?
我有一個自定義用戶控件,它有一個復選框和一個帶有支持依賴屬性的按鈕。 我還有一個帶有 ItemsControl 的 window 並將該控件的“ItemsSource”綁定到包含所述用戶控件的 ObservableCollection。 我的目標是能夠訪問窗口視圖 model 中的依賴項屬性,因此 ...
[英]Dependency Property command's CanExecute() not updating
我有一個用戶控件,並在其中定義了以下屬性:public string MyProperty { get { return (string)GetValue(MyPropertyProperty); } set { SetValue(MyPropertyProperty, va ...
[英]WPF MVVM Dependancy property binding not working
我在 TextBox 控件中使用行為來通過正則表達式過濾輸入。 為此,我添加了一個依賴屬性來獲取正則表達式值。 當我直接在 xaml 中設置該值時,它可以正常工作,但是當我嘗試使用綁定屬性傳遞它時,未在依賴屬性中設置正則表達式值: 使用這種格式時,沒問題: 但不適用於綁定: 我做錯了什么? ...
[英]Create a CustomControl in C# WinUI 3 containing other CustomControls
我是 WinUI 和 XAML 的新手,我正在創建一個包含各種CustomControl的WinUI 3 庫。 它們都是獨立的,可以單獨使用。 但是其中一個控件是通過嵌入庫中的其他一些自定義控件來制作的。 XAML 容器控制<ResourceDictionary xmlns="ht ...
[英]Binding data in custom control
我有一個自定義控件myCustomControl.Xaml 還有一個cs文件myCustomControl.xaml.cs 然后我有mainPage.xaml我設置customId 我不明白為什么我的customId沒有從mainPage.xaml發送到myCustromControl.xaml ? ...
[英]Properly bind DependencyProperty of UserControl in MVVM
我想創建一個可以搜索文件並跟蹤以前使用的文件的文本框。 所以我用一個DependecyProperty制作了一個用戶控件,它應該給我文本框的當前文本和一個按鈕。 但是每次我嘗試綁定到 DependencyProperty 時,綁定到它的屬性仍然是空的。 簡而言之,控件如下所示:<UserCo ...
[英]Unable to set Attached Property in a Setter
我在自定義控件中有一個Style ,我試圖在Label上設置附加屬性。 樣式<Style x:Key="DayNumberStyle" TargetType="Label" BasedOn="{StaticResource {x:Type Label}}"> <Setter ...
[英]Update Property When Another Property Changed
我想在匹配ID更改時更新 class 的Name屬性,我從 web 參考中獲取匹配的Name 。 例如: 所以我有多個 ID,它們都有匹配的名稱,並且它們都將工作相同。 除了 ID 值會根據道具而改變。 尋找解決這個問題的最佳實踐方法 - 非常感謝。 ...
[英]I am creating a dependency property whose type is Window. Could someone tell me which FrameworkPropertyMetadataOptions flag I need to use
我試圖找出用於 Window 類型的FrameworkPropertyMetadataOptions標志。 公共 static 只讀 DependencyProperty RootWindowProperty; static VideoPlayer() { FrameworkPropertyMet ...
[英]Custom UserControl DependencyProperty Binding
我創建了一個自定義UserControl在其他控件中我有以下 在代碼中,兩個綁定都聲明如下 上述控件在另一個控件XAML中使用為 綁定變量TotalGasEuro正確聲明如下 運行應用程序時, GAS會顯示,而在運行時更新的綁定值不會顯示。 (我從圖形部分上面的代碼中刪除了) ...
[英]Specified element is already the logical child of another element, when dynamically adding (binding) custom shape to listbox of panels
這個 InvalidOperationException 帶有消息“指定元素已經是另一個元素的邏輯子元素,請先斷開它”很奇怪,因為它在添加一些 8-9 形狀時發生,但是當我向下滾動它時,它記錄在一些先前的元素 fi shape7 上,或者當我向下滾動后向上滾動幾個元素時元素不是那么多。 有趣的是,當 ...