簡體   English   中英

WPF將控件的zindex綁定到屬性不起作用

[英]WPF Binding a control's zindex to a property doesn't work

如果我將控件的ZIndex綁定到屬性,盡管在調試時明確調用了該屬性(在getter上命中了斷點),但zindex似乎不起作用(即,在運行的應用程序中zindex不變)正確;如果將zindex設置為綁定到屬性而不是XAML中的設置值,則控件上的元素將不再可單擊。 知道為什么,還是要解決此問題? 謝謝您的幫助!

        <views:LaunchableApplicationControl BorderThickness="0" 
            BorderBrush="DarkSlateGray" x:Name="LaunchableApplicationControl"
            Grid.Column="1" Margin="25,150,25,50"  
            Panel.ZIndex="{Binding LaunchableControlZIndex}" 
            Grid.Row="0" Grid.RowSpan="2" 
            DataContext="{Binding LaunchableApplication, Mode=OneWay, 
            Source={StaticResource Locator}}"/>

您可以嘗試DataContext="{Binding ElementName=LaunchableApplicationControl}"並綁定到將設置ZIndex的屬性。 確保實現INotifyPropertyChanged interface

        private int _Zindex;
        public int Zindex
        {
            get { return _Zindex; }
            set
            {
                if (_Zindex == value)
                {
                    return;
                }
                _Zindex = value;
                NotifyPropertyChanged("Zindex");
            }
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM