当前位置: 首页>>代码示例>>C#>>正文


C# Data.Binding类代码示例

本文整理汇总了C#中Windows.UI.Xaml.Data.Binding的典型用法代码示例。如果您正苦于以下问题:C# Binding类的具体用法?C# Binding怎么用?C# Binding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Binding类属于Windows.UI.Xaml.Data命名空间,在下文中一共展示了Binding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditableBlock

		public static sw.FrameworkElementFactory EditableBlock(swd.RelativeSource relativeSource)
		{
			var factory = new sw.FrameworkElementFactory(typeof(EditableTextBlock));
			var binding = new sw.Data.Binding { Path = TextPath, RelativeSource = relativeSource, Mode = swd.BindingMode.TwoWay, UpdateSourceTrigger = swd.UpdateSourceTrigger.PropertyChanged };
			factory.SetBinding(EditableTextBlock.TextProperty, binding);
			return factory;
		}
开发者ID:mhusen,项目名称:Eto,代码行数:7,代码来源:WpfListItemHelper.cs

示例2: FillPathData

        private void FillPathData(Windows.UI.Xaml.Shapes.Path pathInstance, PathType typeOfPath){
            
            var dataPath = string.Empty ;

            if (typeOfPath == PathType.Book)
            {
                dataPath = "M8.15192985534668,0L8.16493034362793,0 8.16493034362793,39.189998626709C8.16493034362793,39.6419982910156 8.31793022155762,40.0549983978271 8.55592918395996,40.2599983215332 8.79993057250977,40.4699993133545 9.08692932128906,40.4329986572266 9.30992889404297,40.173999786377L15.2389297485352,33.1699991226196 20.8559303283691,40.1579990386963C20.9839305877686,40.3139991760254,21.1359310150146,40.3959999084473,21.2879314422607,40.3959999084473L21.6139316558838,40.2689990997314C21.8609313964844,40.0629997253418,22.0179309844971,39.6469993591309,22.0179309844971,39.189998626709L22.0179309844971,0 52.1599340438843,0C53.090934753418,0,53.8439350128174,0.757999420166016,53.8439350128174,1.6879997253418L53.8439350128174,49.3569984436035C53.8439350128174,50.2879981994629,53.090934753418,51.0459976196289,52.1599340438843,51.0459976196289L52.1399345397949,51.0410003662109C52.0039348602295,51.0699996948242,51.8759346008301,51.0909996032715,51.7449340820313,51.0909996032715L8.14793014526367,51.0909996032715C5.61592864990234,51.0909996032715 3.5399284362793,53.0789985656738 3.39693069458008,55.5789985656738 3.39693069458008,55.7309989929199 3.40092849731445,55.8460006713867 3.40092849731445,55.9209976196289L3.39292907714844,56.0529975891113C3.49493026733398,58.5929985046387,5.58692932128906,60.6279983520508,8.14793014526367,60.6279983520508L50.4719343185425,60.6279983520508 50.4719343185425,55.9669990539551C50.4719343185425,55.0359992980957 51.2299346923828,54.2779998779297 52.1599340438843,54.2779998779297 53.090934753418,54.2779998779297 53.8439350128174,55.0359992980957 53.8439350128174,55.9669990539551L53.8439350128174,62.3120002746582C53.8439350128174,63.246997833252,53.090934753418,64,52.1599340438843,64L7.89292907714844,64 7.63792991638184,63.9749984741211C3.3879280090332,63.7070007324219,0.00792694091796875,60.1749992370605,0.00792694091796875,55.8589973449707L0.0229301452636719,55.5669975280762C-0.0290718078613281,50.5599994659424,0.0229301452636719,12.4609990119934,0.0279273986816406,8.3179988861084L0.0119285583496094,8.14099884033203C0.0119285583496094,3.65299892425537,3.6649284362793,0,8.15192985534668,0z";
               
            }
            else if (typeOfPath == PathType.Key) {

                dataPath = "M16.547848,26.872497C14.451092,26.916562 12.365034,27.710413 10.729302,29.266098 7.2240894,32.589393 7.0834706,38.118687 10.403706,41.615683 13.72137,45.118677 19.252512,45.263676 22.752474,41.941881 26.247238,38.621584 26.401036,33.097193 23.078072,29.594298 21.314234,27.73567 18.92417,26.822555 16.547848,26.872497z M47.555126,0.0002117157C47.726013,0.0044841766,47.895291,0.073574066,48.021641,0.20638657L52.778168,5.1985388C53.03077,5.4641666,53.020371,5.888484,52.754769,6.1409225L52.232945,6.6370945 58.379608,13.115402C58.632122,13.382402,58.621121,13.806803,58.354809,14.058203L56.356011,15.956708C56.089798,16.207609,55.665879,16.197409,55.413365,15.930308L49.269745,9.4546347 48.00716,10.655153 52.407509,15.294587C52.660187,15.560289,52.649086,15.984593,52.382813,16.237495L50.384396,18.133013C50.118122,18.386015,49.694359,18.375215,49.441685,18.109612L45.04353,13.473104 30.99349,26.832494 31.170538,27.124847C35.031944,33.685067 34.017586,42.279621 28.253817,47.748075 21.549486,54.107365 10.954499,53.828564 4.5965569,47.125475 -1.7705653,40.417484 -1.4855343,29.826198 5.21898,23.462906 10.672487,18.294763 18.680851,17.507213 24.908787,20.994482L25.088602,21.09812 47.078934,0.18294907C47.211735,0.056484222,47.384236,-0.0040607452,47.555126,0.0002117157z";
            }


            if (!string.IsNullOrEmpty(dataPath))
            {
                var b = new Binding { Source = dataPath };

                BindingOperations.SetBinding(pathInstance, Windows.UI.Xaml.Shapes.Path.DataProperty, b);
            }
        


        }
开发者ID:ValdimarThor,项目名称:X,代码行数:25,代码来源:Path.cs

示例3: HandlePlayerControlProgressBarBezzelManipulationStarted

        private void HandlePlayerControlProgressBarBezzelManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
        {
            ProgressBarScrubView.Visibility = Visibility.Visible;

            BindingExpression bindingExpression = PlayerControlProgressBarCompleted.GetBindingExpression(Rectangle.WidthProperty);
            savedWidthBinding = bindingExpression.ParentBinding;
        }
开发者ID:jevonsflash,项目名称:ProjectMato,代码行数:7,代码来源:LandingPage.xaml.cs

示例4: OnWrapOptionsAppBarButtonClick

        void OnWrapOptionsAppBarButtonClick(object sender, RoutedEventArgs args)
        {
            // Create dialog
            WrapOptionsDialog wrapOptionsDialog = new WrapOptionsDialog
            {
                TextWrapping = txtbox.TextWrapping
            };

            // Bind dialog to TextBox
            Binding binding = new Binding
            {
                Source = wrapOptionsDialog,
                Path = new PropertyPath("TextWrapping"),
                Mode = BindingMode.TwoWay
            };
            txtbox.SetBinding(TextBox.TextWrappingProperty, binding);

            // Create popup
            Popup popup = new Popup
            {
                Child = wrapOptionsDialog,
                IsLightDismissEnabled = true
            };

            // Adjust location based on content size
            wrapOptionsDialog.SizeChanged += (dialogSender, dialogArgs) =>
            {
                popup.VerticalOffset = this.ActualHeight - wrapOptionsDialog.ActualHeight
                                                         - this.BottomAppBar.ActualHeight - 48;
                popup.HorizontalOffset = 48;
            };

            // Open the popup
            popup.IsOpen = true;
        }
开发者ID:BeyondVincent,项目名称:WindowsStoreAppStepByStep,代码行数:35,代码来源:MainPage.xaml.cs

示例5: MainPage

        public MainPage()
        {
            this.InitializeComponent();

            Student stu = new Student { Name = "张三", Course = "C语言" };

            // 实例化Binding对象
            Windows.UI.Xaml.Data.Binding nameBinding = new Windows.UI.Xaml.Data.Binding();
            // 设置源
            nameBinding.Source = stu;
            // 制定获取数据源中的Name属性
            nameBinding.Path = new PropertyPath("Name");

            Windows.UI.Xaml.Data.Binding courseBinding = new Windows.UI.Xaml.Data.Binding();
            courseBinding.Source = stu;
            courseBinding.Path = new PropertyPath("Course");

            // 绑定方向为单向
            nameBinding.Mode = courseBinding.Mode = BindingMode.OneWay;

            // 将 Binding 实例与TextBlock空间的Text属性关联
            tbName.SetBinding(TextBlock.TextProperty, nameBinding);
            tbCourse.SetBinding(TextBlock.TextProperty, courseBinding);

            TaskItem item = new TaskItem
            {
                TaskID = 1000251,
                TaskName = "示例工序",
                TaskDesc = "示例描述。",
                TaskProgress = 60d
            };
            this.layoutRoot.DataContext = item;
        }
开发者ID:forehalo,项目名称:UWP-dev,代码行数:33,代码来源:MainPage.xaml.cs

示例6: OnNavigatedTo

 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.  The Parameter
 /// property is typically used to configure the page.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     Thickness thick;
     thick.Top = 400;
     TextBlock txt = new TextBlock
     {
         Text = "Binding This Style in C#",
         VerticalAlignment = VerticalAlignment.Center,
         HorizontalAlignment = HorizontalAlignment.Center,
         Margin = thick,
         FontSize = 60,
         FontFamily = new FontFamily("Matura MT Script Capitals")
     };
     // Dynamically bind to an existed style.
     // 1. Setup the source.
     PropertyPath pPath = new PropertyPath("Foreground");
     Binding target = new Binding
     {
         ElementName = "topTxt",
         Path = pPath
     };
     // 2. Bind to the source. It is a DependencyObject, so you must use TextBlock.Foreground instead of Foreground.
     txt.SetBinding(TextBlock.ForegroundProperty, target);
     (this.Content as Grid).Children.Add(txt);
 }
开发者ID:ZWin8,项目名称:MetroGit,代码行数:30,代码来源:DataBindingDemo.xaml.cs

示例7: VertexControl

        /// <summary>
        /// Create vertex visual control
        /// </summary>
        /// <param name="vertexData">Vertex data object</param>
        /// <param name="bindToDataObject">Bind DataContext to the Vertex data. True by default. </param>
        public VertexControl(object vertexData,  bool bindToDataObject = true)
        {
            DefaultStyleKey = typeof (VertexControl);
            if (bindToDataObject) DataContext = vertexData;
            Vertex = vertexData;

            EventOptions = new VertexEventOptions(this);
            foreach(var item in Enum.GetValues(typeof(EventType)).Cast<EventType>())
                UpdateEventhandling(item);

            IsEnabledChanged += VertexControl_IsEnabledChanged;

            var xBinding = new Binding
            {
                Path = new PropertyPath("(Canvas.Left)"),
                Source = this
            };
            SetBinding(TestXProperty, xBinding);
            var yBinding = new Binding
            {
                Path = new PropertyPath("(Canvas.Top)"),
                Source = this
            };
            SetBinding(TestYProperty, yBinding);
        }
开发者ID:aliaspilote,项目名称:TX52,代码行数:30,代码来源:VertexControl.cs

示例8: OnLocationDisplayPropertyChanged

		private static void OnLocationDisplayPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			var ctrl = (LocationDisplayToggle)d;
			if (e.NewValue != null)
			{
				Binding b = new Binding()
				{
					Source = e.NewValue,
					Path = new PropertyPath("IsEnabled"),
					Mode = BindingMode.TwoWay
				};
				ctrl.SetBinding(IsLocationEnabledProperty, b);
				b = new Binding()
				{
					Source = e.NewValue,
					Path = new PropertyPath("AutoPanMode"),
					Mode = BindingMode.TwoWay
				};
				ctrl.SetBinding(ModeProperty, b);
			}
			else
			{
				ctrl.SetBinding(IsLocationEnabledProperty, null);
				ctrl.SetBinding(ModeProperty, null);
			}
			ctrl.UpdateIcon();
		}
开发者ID:Esri,项目名称:arcgis-runtime-demos-dotnet,代码行数:27,代码来源:LocationDisplayToggle.xaml.cs

示例9: OnNavigatedTo

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
#if GIVEUP
            // With ItemsSource="{Binding}" in XAML
            Binding bind = new Binding();
            bind.Source = App.CurrentDisasterList;
            bind.Mode = BindingMode.OneTime; // You would think oneway would protect App.CurrentDisasterList from changes, but it doesn't
            EventComboBox.SetBinding(ComboBox.ItemsSourceProperty, bind);

#endif
            //EventComboBox.ItemsSource = App.CurrentDisasterList; //Binding to List is good for unchanging collection.  Bind to ObservableCollection if changing.
            /// No: EventComboBox.DataContext = App.CurrentDisasterList;  also crashes: App.CurrentDisasterListForCombo
            //foreach (TP_EventsDataItem i in App.CurrentDisasterList)
            //    EventComboBox.Items.Add(i);

            if(App.CurrentDisaster.EventName == "")
                return;
            int count = 0;
            foreach (var i in App.CurrentDisasterList) //TP_EventsDataList.GetEvents())
            {
                if (i.EventName == App.CurrentDisaster.EventName)  // Could match instead throughout on EventShortName or EventNumericID
                {
                    EventListView.SelectedIndex = count; //EventComboBox.SelectedItem = i;
                    break;
                }
                count++;
            }
        }
开发者ID:TriagePic,项目名称:TriagePic-WinStore,代码行数:29,代码来源:ChecklistPage.xaml.cs

示例10: SetBinding

 /// <summary>
 /// Sets a binding from code
 /// </summary>
 /// <param name="element"></param>
 /// <param name="property"></param>
 /// <param name="source"></param>
 /// <param name="path"></param>
 /// <param name="converter"></param>
 public static void SetBinding(FrameworkElement element, DependencyProperty property, object source, string path, IValueConverter converter = null)
 {
     Binding binding = new Binding();
     binding.Source = source;
     binding.Path = new PropertyPath(path);
     binding.Converter = converter;
     element.SetBinding(property, binding);
 }
开发者ID:knowlatest,项目名称:Windows8StartKit,代码行数:16,代码来源:BindingHelper.cs

示例11: DependencyPropertyChangedHelper

 /// <summary>
 /// Constructor for the helper. 
 /// </summary>
 /// <param name="source">Source object that exposes the DependencyProperty you wish to monitor.</param>
 /// <param name="propertyPath">The name of the property on that object that you want to monitor.</param>
 public DependencyPropertyChangedHelper(DependencyObject source, string propertyPath) {
     // Set up a binding that flows changes from the source DependencyProperty through to a DP contained by this helper 
     Binding binding = new Binding {
         Source = source,
         Path = new PropertyPath(propertyPath)
     };
     BindingOperations.SetBinding(this, HelperProperty, binding);
 }
开发者ID:ronlemire2,项目名称:PrismRT-CodeGen-v2.1,代码行数:13,代码来源:DependencyPropertyChangedHelper.cs

示例12: BindProperty

 public static void BindProperty(FrameworkElement element, object source,
     string path, DependencyProperty property, BindingMode mode)
 {
     var binding = new Binding();
     binding.Path = new PropertyPath(path);
     binding.Source = source;
     binding.Mode = mode;
     element.SetBinding(property, binding);
 }
开发者ID:kondoumh,项目名称:MetroCsStudyDraw,代码行数:9,代码来源:BindingHelper.cs

示例13: SetVideoPresenters

        private void SetVideoPresenters()
        {
            var boolToVisConverter = new BooleanToVisibilityConverter();

#if WIN10
            var peerSwapChainPanel = new WebRTCSwapChainPanel.WebRTCSwapChainPanel();

            var peerHandleBinding = new Binding
            {
                Source = DataContext,
                Path = new PropertyPath("RemoteSwapChainPanelHandle"),
                Mode = BindingMode.OneWay
            };
            peerSwapChainPanel.SetBinding(
                WebRTCSwapChainPanel.WebRTCSwapChainPanel.SwapChainPanelHandleProperty,
                peerHandleBinding);

            PeerVideoPresenter.Content = peerSwapChainPanel;

            var selfSwapChainPanel = new WebRTCSwapChainPanel.WebRTCSwapChainPanel();

            var selfHandleBinding = new Binding
            {
                Source = DataContext,
                Path = new PropertyPath("LocalSwapChainPanelHandle"),
                Mode = BindingMode.OneWay
            };
            selfSwapChainPanel.SetBinding(
                WebRTCSwapChainPanel.WebRTCSwapChainPanel.SwapChainPanelHandleProperty,
                selfHandleBinding);

            var selfSizeBinding = new Binding
            {
                Source = DataContext,
                Path = new PropertyPath("LocalNativeVideoSize"),
            };
            selfSwapChainPanel.SetBinding(
                WebRTCSwapChainPanel.WebRTCSwapChainPanel.SizeProperty,
                selfSizeBinding);

            SelfVideoPresenter.Content = selfSwapChainPanel;
#endif

#if WIN81
            _peerMediaElement = new MediaElement
            {
                RealTimePlayback = true
            };
            PeerVideoPresenter.Content = _peerMediaElement;

            _selfMediaElement = new MediaElement
            {
                RealTimePlayback = true
            };
            SelfVideoPresenter.Content = _selfMediaElement;            
#endif
        }
开发者ID:hungdluit,项目名称:ChatterBox,代码行数:57,代码来源:CallView.xaml.cs

示例14: NowPlayingBar

        public NowPlayingBar()
        {
            InitializeComponent();

            var visBinding = new Binding {Source = DataContext, Path = new PropertyPath("CurrentQueue")};
            SetBinding(IsVisibleProperty, visBinding);

            (App.Locator.CollectionService as CollectionService).PropertyChanged += OnPropertyChanged;
        }
开发者ID:jayharry28,项目名称:Audiotica,代码行数:9,代码来源:NowPlayingBar.xaml.cs

示例15: DependencyPropertyChangedHelper

		public DependencyPropertyChangedHelper(DependencyObject source, string propertyPath)
		{
			Binding binding = new Binding
			{
				Source = source,
				Path = new PropertyPath(propertyPath)
			};
			BindingOperations.SetBinding(this, HelperProperty, binding);
		}
开发者ID:valeronm,项目名称:handyNews,代码行数:9,代码来源:DependencyPropertyChangedHelper.cs


注:本文中的Windows.UI.Xaml.Data.Binding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。