本文整理汇总了C#中System.Windows.Controls.ContentControl类的典型用法代码示例。如果您正苦于以下问题:C# ContentControl类的具体用法?C# ContentControl怎么用?C# ContentControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentControl类属于System.Windows.Controls命名空间,在下文中一共展示了ContentControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
/// <summary>
/// 动态显示内容
/// </summary>
/// <param name="target"></param>
/// <param name="duration"></param>
public static void Show(ContentControl target, double duration = .8)
{
ThicknessAnimation animtion = new ThicknessAnimation()
{
From = new Thickness(target.Margin.Left + 80, target.Margin.Top, target.Margin.Right, target.Margin.Bottom),
To = new Thickness(160, 0, 0, 0),
Duration = TimeSpan.FromSeconds(duration),
FillBehavior = FillBehavior.HoldEnd,
AccelerationRatio = .5,
EasingFunction = be
};
DoubleAnimation animtion2 = new DoubleAnimation()
{
From = 0,
To = 1,
Duration = TimeSpan.FromSeconds(duration),
FillBehavior = FillBehavior.HoldEnd,
AccelerationRatio = .5,
EasingFunction = be
};
target.BeginAnimation(ContentControl.MarginProperty, animtion);
target.BeginAnimation(ContentControl.OpacityProperty, animtion2);
}
示例2: AddFeedbackAdorner
/// <summary>
/// Add a feedback adorner to a UI element.
/// This is used to show when a connection can or can't be attached to a particular connector.
/// 'indicator' will be a view-model object that is transformed into a UI element using a data-template.
/// </summary>
private void AddFeedbackAdorner(FrameworkElement adornedElement, object indicator)
{
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
if (feedbackAdorner != null)
{
if (feedbackAdorner.AdornedElement == adornedElement)
{
// No change.
return;
}
adornerLayer.Remove(feedbackAdorner);
feedbackAdorner = null;
}
//
// Create a content control to contain 'indicator'.
// The view-model object 'indicator' is transformed into a UI element using
// normal WPF data-template rules.
//
ContentControl adornerElement = new ContentControl();
adornerElement.HorizontalAlignment = HorizontalAlignment.Left;
adornerElement.VerticalAlignment = VerticalAlignment.Center;
adornerElement.Content = indicator;
//
// Create the adorner and add it to the adorner layer.
//
feedbackAdorner = new FrameworkElementAdorner(adornerElement, adornedElement);
adornerLayer.Add(feedbackAdorner);
}
示例3: DialogManager
public DialogManager(
ContentControl parent,
Dispatcher dispatcher)
{
_dispatcher = dispatcher;
_dialogHost = new DialogLayeringHelper(parent);
}
示例4: ContentAdorner
// Be sure to call the base class constructor.
public ContentAdorner(UIElement adornedElement)
: base(adornedElement)
{
this.children = new VisualCollection(this);
//
// Create the content control
//
var contentControl = new ContentControl();
//
// Bind the content control to the Adorner's ContentTemplate property, so we know what to display
//
var contentTemplateBinding = new Binding();
contentTemplateBinding.Path = new PropertyPath(AdornerContentTemplateProperty);
contentTemplateBinding.Source = adornedElement;
contentControl.SetBinding(ContentControl.ContentTemplateProperty, contentTemplateBinding);
//
// Add the ContentControl as a child
//
this.child = contentControl;
this.children.Add(this.child);
this.AddLogicalChild(this.child);
}
示例5: PopupWrapper
/// <summary>
/// Initializes a new instance of <see cref="PopupWrapper"/>.
/// </summary>
public PopupWrapper()
{
this.container = new ContentControl();
this.popUp = new Popup();
this.popUp.Child = this.container;
}
示例6: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
m_leftButton = (Button)GetTemplateChild("PART_LeftButton");
m_rightButton = (Button)GetTemplateChild("PART_RightButton");
m_contentControl = (ContentControl)GetTemplateChild("PART_Content");
m_viewArea = (Border)GetTemplateChild("PART_ViewArea");
if (m_leftButton == null || m_rightButton == null || m_contentControl == null || m_viewArea == null)
throw new Exception("Templet must contain PART_ViewArea, PART_Content, PART_UpButton and PART_DownButton");
m_leftButton.Click += LeftButtonOnClick;
m_rightButton.Click += RightButtonOnClick;
m_contentControl.Content = Content;
//GradientStopCollection gradientStopCollection = new GradientStopCollection();
//m_topGradientStop = new GradientStop(Colors.Transparent, 0);
//gradientStopCollection.Add(m_topGradientStop);
//gradientStopCollection.Add(new GradientStop(Colors.Black, 0.01));
//gradientStopCollection.Add(new GradientStop(Colors.Black, 0.99));
//m_buttomGradientStop = new GradientStop(Colors.Transparent, 1);
//gradientStopCollection.Add(m_buttomGradientStop);
//m_viewArea.OpacityMask = new LinearGradientBrush(gradientStopCollection) { StartPoint = new Point(0, 0), EndPoint = new Point(1, 0)};
m_viewArea.SizeChanged += OnSizeChanged;
if (m_thicknessAnimation != null)
Storyboard.SetTarget(m_thicknessAnimation, m_contentControl);
Update();
}
示例7: ResizeThumb_DragStarted
private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
{
this.designerItem = this.DataContext as ContentControl;
if (this.designerItem != null)
{
this.canvas = VisualTreeHelper.GetParent(this.designerItem) as ContentPresenter;
if (this.canvas != null)
{
this.transformOrigin = this.designerItem.RenderTransformOrigin;
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (this.rotateTransform != null)
{
this.angle = this.rotateTransform.Angle * Math.PI / 180.0;
}
else
{
this.angle = 0.0d;
}
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.canvas);
if (adornerLayer != null)
{
this.adorner = new SizeAdorner(this.designerItem);
adornerLayer.Add(this.adorner);
}
}
}
}
示例8: OrderInput
//Zmienna do blokowania wrzucania starego zamowienia do bazy
public OrderInput(ContentControl contentControl)
{
_contentControl = contentControl;
_order = new Order();
InitializeComponent();
_isOrderBeingRead = false;
ClientNumberTextBox.Provider =
new SuggestionProvider(
x => Data.PhoneNumbers.Where(stringToCheck => stringToCheck.ToString().Contains(x)));
StreetTextBox.Provider =
new SuggestionProvider(
x =>
Data.StreetList.Where(stringToCheck => stringToCheck.ToString().ToLower().Contains(x.ToLower())));
foreach (var pizza in Data.PizzasPrizeDictionary.Keys)
AllPizzasList.Items.Add(pizza);
foreach (var topping in Data.ToppingsDictionary.Values)
AllToppingsList.Items.Add(topping);
foreach (var topping in Data.SizePrizeDictionary.Keys)
AllSizeList.Items.Add(topping);
foreach (var topping in Data.DoughsDictionary.Values)
AllDoughsList.Items.Add(topping);
}
示例9: setup
private void setup()
{
if (!DesignerProperties.GetIsInDesignMode(this))
return;
var parent = this.Parent as FrameworkElement;
while (parent != null)
{
if (parent.Parent == null)
{
var window = parent as ContentControl;
if (window != null)
{
this.window = window;
this.togglChrome = new TogglChrome();
var oldContent = window.Content as UIElement;
window.Content = this.togglChrome;
this.togglChrome.SetContent(oldContent);
this.refreshData();
return;
}
}
parent = parent.Parent as FrameworkElement;
}
throw new Exception("TogglWindowDesignTimeConverter must be descendend of ContentControl.\n\nTry rebuilding.");
}
示例10: DetectCollision
public bool DetectCollision(ContentControl controlOne, ContentControl controlTwo)
{
// new Rect(X1, Y1, X2, Y2);
Rect c1Rect = new Rect(
new Point(Convert.ToDouble(controlOne.GetValue(Canvas.LeftProperty)),
Convert.ToDouble(controlOne.GetValue(Canvas.TopProperty))
),
new Point(Convert.ToDouble(controlOne.GetValue(Canvas.LeftProperty)) + controlOne.ActualWidth,
Convert.ToDouble(controlOne.GetValue(Canvas.TopProperty)) + controlOne.ActualHeight
)
);
Rect c2Rect = new Rect(
new Point(Convert.ToDouble(controlTwo.GetValue(Canvas.LeftProperty)),
Convert.ToDouble(controlTwo.GetValue(Canvas.TopProperty))
),
new Point(Convert.ToDouble(controlTwo.GetValue(Canvas.LeftProperty)) + controlTwo.ActualWidth,
Convert.ToDouble(controlTwo.GetValue(Canvas.TopProperty)) + controlTwo.ActualHeight
)
);
c1Rect.Intersect(c2Rect);
return !(c1Rect == Rect.Empty);
}
示例11: MyMapView_MapViewTapped
private async void MyMapView_MapViewTapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
{
MyMapView.Overlays.Items.Clear();
IEnumerable<KmlFeature> features = await (MyMapView.Map.Layers["kmlLayer"] as KmlLayer).HitTestAsync(MyMapView, e.Position);
if (features.Count() > 0)
{
if (!string.IsNullOrWhiteSpace(features.FirstOrDefault().BalloonStyle.FormattedText))
{
//Create WebBrowser to show the formatted text
var browser = new System.Windows.Controls.WebBrowser();
browser.NavigateToString(features.FirstOrDefault().BalloonStyle.FormattedText);
//Get the KmlPlacemark position
var featurePosition = (features.FirstOrDefault() as KmlPlacemark).Extent;
//Create ContentControl
var cControl = new ContentControl()
{
Content = browser,
MaxHeight = 500,
MaxWidth = 450
};
//Add the ContentControl to MapView.Overlays
MapView.SetViewOverlayAnchor(cControl, featurePosition.GetCenter());
MyMapView.Overlays.Items.Add(cControl);
}
}
}
示例12: InitializeComponent
public void InitializeComponent()
{
if (!this._contentLoaded)
{
this._contentLoaded = true;
Application.LoadComponent(this, new Uri("/TWC.OVP;component/Views/Shell/OnDemandShellView.xaml", UriKind.Relative));
this.userControl = (UserControl) base.FindName("userControl");
this.LayoutRoot = (Grid) base.FindName("LayoutRoot");
this.AssetInfoStates = (VisualStateGroup) base.FindName("AssetInfoStates");
this.ShowAssetInfo = (VisualState) base.FindName("ShowAssetInfo");
this.InfoPanelIn = (Storyboard) base.FindName("InfoPanelIn");
this.HideAssetInfo = (VisualState) base.FindName("HideAssetInfo");
this.ShowSmallAssetInfoPopupBubble = (VisualState) base.FindName("ShowSmallAssetInfoPopupBubble");
this.CaptionSettingsStates = (VisualStateGroup) base.FindName("CaptionSettingsStates");
this.ShowCaptionSettings = (VisualState) base.FindName("ShowCaptionSettings");
this.HideCaptionSettings = (VisualState) base.FindName("HideCaptionSettings");
this.CaptionSettingsPopupStates = (VisualStateGroup) base.FindName("CaptionSettingsPopupStates");
this.ShowSettingsBubble = (VisualState) base.FindName("ShowSettingsBubble");
this.HideSettingsBubble = (VisualState) base.FindName("HideSettingsBubble");
this.BackgroundRectangle = (Rectangle) base.FindName("BackgroundRectangle");
this.AssetViewer = (ContentControl) base.FindName("AssetViewer");
this.ClickToggleControlBarAction = (ActionMessage) base.FindName("ClickToggleControlBarAction");
this.controller = (OnDemandController) base.FindName("controller");
this.assetInfoContentControl = (BubbleContentControl) base.FindName("assetInfoContentControl");
this.captionBubble = (BubbleContentControl) base.FindName("captionBubble");
this.CaptionSettings = (ContentControl) base.FindName("CaptionSettings");
this.Interaction = (ContentControl) base.FindName("Interaction");
}
}
示例13: root_Loaded
private void root_Loaded(object sender, RoutedEventArgs e)
{
if (!_isLoaded)
{
if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
{
_parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
}
else
_parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
if (_parentWindow != null)
{
if (Scheduler == null)
{
Scheduler = _parentWindow.DataContext as C1Scheduler;
}
if (_parentWindow is Window)
{
((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
}
else
{
((C1Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
((C1Window)_parentWindow).WindowStateChanged += new EventHandler<PropertyChangedEventArgs<C1WindowState>>(_parentWindow_WindowStateChanged);
}
}
UpdateTitle();
remList.SelectionChanged += new SelectionChangedEventHandler(remList_SelectionChanged);
UpdateTimer(1);
remList.Focus();
_isLoaded = true;
}
ShowRemindersControl_CollectionChanged(null, null);
}
示例14: MainToolsTab_Selected
private void MainToolsTab_Selected(object sender, RoutedEventArgs e)
{
var listBoxItem = sender as ListBoxItem;
listBoxItem.Selected -= MainToolsTab_Selected;
mainToolsView = KCVUIHelper.KCVContent.FindVisualChildren<ContentControl>().Where(x => x.DataContext is ToolsViewModel).Last();
mainToolsView.LayoutUpdated += MainToolsView_LayoutUpdated;
}
示例15: OnPropertyChanged
private static void OnPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
var taskbarItemInfo = (TaskbarItemInfo) dependencyObject;
object content = GetContent(taskbarItemInfo);
DataTemplate template = GetTemplate(taskbarItemInfo);
if (template == null || content == null)
{
taskbarItemInfo.Overlay = null;
return;
}
const int ICON_WIDTH = 32;
const int ICON_HEIGHT = 32;
var bmp =
new RenderTargetBitmap(ICON_WIDTH, ICON_HEIGHT, 96, 96, PixelFormats.Default);
var root = new ContentControl
{
ContentTemplate = template,
Content = content
};
root.Arrange(new Rect(0, 0, ICON_WIDTH, ICON_HEIGHT));
bmp.Render(root);
taskbarItemInfo.Overlay = bmp;
}