本文整理汇总了C#中Windows.UI.Xaml.Controls.ContentControl.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# ContentControl.SetBinding方法的具体用法?C# ContentControl.SetBinding怎么用?C# ContentControl.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.ContentControl
的用法示例。
在下文中一共展示了ContentControl.SetBinding方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: scrollViewer_Loaded
private void scrollViewer_Loaded(object sender, RoutedEventArgs e)
{
scrollViewer.Loaded -= scrollViewer_Loaded;
scrollViewer.ViewChanged += ScrollViewer_ViewChanged;
currentTopGroupHeader = this.scrollViewer.FindDescendantByName("TopGroupHeader") as ContentControl;
Binding binding = new Binding();
binding.Source = this;
binding.Mode = BindingMode.OneWay;
binding.Path = new PropertyPath("GroupHeaderTemplate");
currentTopGroupHeader.SetBinding(ContentControl.ContentTemplateProperty, binding);
currentTopGroupHeader.Visibility = Visibility.Collapsed;
if (scrollViewer.VerticalOffset == 0)
{
CreateVisual();
}
else
{
scrollViewer.RegisterPropertyChangedCallback(ScrollViewer.VerticalOffsetProperty, new DependencyPropertyChangedCallback(OnScrollViewerVerticalOffsetChanged));
}
}
示例2: UpdateSelectedValue
/// <summary>
/// Update the selected value of the of the TreeView based on the value
/// of the currently selected TreeViewItem and the SelectedValuePath.
/// </summary>
/// <param name="item">
/// Value of the currently selected TreeViewItem.
/// </param>
private void UpdateSelectedValue(object item)
{
if (item != null)
{
string path = SelectedValuePath;
if (string.IsNullOrEmpty(path))
{
SelectedValue = item;
}
else
{
// Since we don't have the ability to evaluate a
// BindingExpression, we'll just create a new temporary
// control to bind the value to which we can then copy out
Binding binding = new Binding
{
Path = new PropertyPath(path),
Source = item
};
ContentControl temp = new ContentControl();
temp.SetBinding(ContentControl.ContentProperty, binding);
SelectedValue = temp.Content;
// Remove the Binding once we have the value (this is
// especially important if the value is a UIElement because
// it should not exist in the visual tree once we've
// finished)
temp.ClearValue(ContentControl.ContentProperty);
}
}
else
{
ClearValue(SelectedValueProperty);
}
}
示例3: ControlWithExistingBindingOnContentWithNullValueThrows
public async Task ControlWithExistingBindingOnContentWithNullValueThrows()
{
await ExecuteOnUIThread(() =>
{
var control = new ContentControl();
Binding binding = new Binding
{
Path = new PropertyPath("ObjectContents"),
Source = new SimpleModel() { ObjectContents = null }
};
control.SetBinding(ContentControl.ContentProperty, binding);
IRegionAdapter adapter = new TestableContentControlRegionAdapter();
Assert.ThrowsException<InvalidOperationException>(
() => (MockPresentationRegion)adapter.Initialize(control, "Region1"),
"ContentControl's Content property is not empty.");
});
}
示例4: ContentChanged
private static void ContentChanged(ContentControl control, IPropertyChangedArgs<string> args)
{
control.SetBinding(ContentControl.ContentProperty, args.NewValue);
}
示例5: CreateControl
private Control CreateControl(object content)
{
var control = new ContentControl
{
Content = content,
RenderTransformOrigin = new Point(0.5, 0.5)
};
control.SetBinding(ContentControl.ContentTemplateProperty, new Binding { Source = this, Path = new PropertyPath("ItemTemplate") });
return control;
}
示例6: CreateGroupHeader
private ContentControl CreateGroupHeader(IGroupHeader group)
{
ContentControl groupheader = new ContentControl();
Binding binding = new Binding();
binding.Source = this;
binding.Mode = BindingMode.OneWay;
binding.Path = new PropertyPath("GroupHeaderTemplate");
groupheader.SetBinding(ContentControl.ContentTemplateProperty, binding);
groupheader.DataContext = group;
groupheader.HorizontalAlignment = HorizontalAlignment.Stretch;
groupheader.HorizontalContentAlignment = HorizontalAlignment.Stretch;
groupheader.VerticalAlignment = VerticalAlignment.Top;
groupheader.VerticalContentAlignment = VerticalAlignment.Stretch;
return groupheader;
}