本文整理汇总了C#中System.Windows.Controls.ContentControl类的典型用法代码示例。如果您正苦于以下问题:C# ContentControl类的具体用法?C# ContentControl怎么用?C# ContentControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentControl类属于System.Windows.Controls命名空间,在下文中一共展示了ContentControl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:ONEWateR,项目名称:FlowMonitor,代码行数:31,代码来源:CAAnimation.cs
示例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);
}
开发者ID:xcasadio,项目名称:FlowGraph,代码行数:37,代码来源:NetworkView_ConnectionDragging.cs
示例3: DialogManager
public DialogManager(
ContentControl parent,
Dispatcher dispatcher)
{
_dispatcher = dispatcher;
_dialogHost = new DialogLayeringHelper(parent);
}
开发者ID:tsbrzesny,项目名称:rma-alzheimer,代码行数:7,代码来源:DialogManager.cs
示例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);
}
开发者ID:jrgcubano,项目名称:zetbox,代码行数:26,代码来源:ContentAdorner.cs
示例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;
}
开发者ID:eslahi,项目名称:prism,代码行数:10,代码来源:PopupWrapper.Silverlight.cs
示例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();
}
开发者ID:grarup,项目名称:SharpE,代码行数:32,代码来源:HorizontalEdgeButtonScroll.cs
示例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);
}
}
}
}
开发者ID:nakioman,项目名称:furryrun-editor,代码行数:31,代码来源:ResizeThumb.cs
示例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);
}
开发者ID:rafalmargas,项目名称:ProjektPizzeria,代码行数:26,代码来源:OrderInput.xaml.cs
示例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.");
}
开发者ID:ThomasAvery,项目名称:toggldesktop,代码行数:29,代码来源:TogglChromeDesignTimeConverter.cs
示例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);
}
开发者ID:BrianJVarley,项目名称:Side_Scroller_Mini_Game,代码行数:25,代码来源:MainPage.xaml.cs
示例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);
}
}
}
开发者ID:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:32,代码来源:KMLPopups.xaml.cs
示例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");
}
}
开发者ID:BigBri41,项目名称:TWCTVWindowsPhone,代码行数:29,代码来源:OnDemandShellView.cs
示例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);
}
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:34,代码来源:ShowRemindersControl.xaml.cs
示例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;
}
开发者ID:xiaoqi0326,项目名称:KCV.Landscape,代码行数:7,代码来源:LandscapeHacker.cs
示例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;
}
开发者ID:benneeh,项目名称:wScreenshot,代码行数:27,代码来源:TaskBarItemOverlay.cs
示例16: PagePerformance
public PagePerformance()
{
InitializeComponent();
StackPanel panelContent = new StackPanel();
panelContent.Margin = new Thickness(10, 0, 10, 0);
panelContent.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
ContentControl txtHeader = new ContentControl();
txtHeader.ContentTemplate = this.Resources["PerformanceHeader"] as DataTemplate;
txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
panelContent.Children.Add(txtHeader);
ListBox lbCounters = new ListBox();
lbCounters.ItemTemplate = this.Resources["PerformanceItem"] as DataTemplate;
lbCounters.MaxHeight = GraphicsHelpers.GetContentHeight() - 50;
lbCounters.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
foreach (string pageCounter in PerformanceCounters.GetPages())
lbCounters.Items.Add(pageCounter);
panelContent.Children.Add(lbCounters);
base.setContent(panelContent);
base.setHeaderContent("Performance Counters");
showPage(this);
}
开发者ID:pedromorgan,项目名称:theairlineproject-cs,代码行数:30,代码来源:PagePerformance.xaml.cs
示例17: ShouldThrowArgumentNullException
public void ShouldThrowArgumentNullException()
{
ContentControl parent = new ContentControl();
TextBlock child = new TextBlock();
parent.Content = child;
TreeHelper.FindAncestor(child, null);
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:7,代码来源:TreeHelperFixture.cs
示例18: AddedView
void AddedView(object sender, AddedViewEventArgs e)
{
NavigationButton button = new NavigationButton();
StackPanel panel = new StackPanel();
TextBlock title = new TextBlock();
title.TextAlignment = TextAlignment.Center;
title.Text = e.View.Title;
panel.Children.Add(title);
Image icon = new Image();
icon.Source = new BitmapImage(new Uri("/Omniscient.Foundation.Contrib.Silverlight;Component/Resources/application_side_boxes.png", UriKind.Relative));
icon.Stretch = Stretch.Fill;
ContentControl iconPlaceholder = new ContentControl();
iconPlaceholder.Height = 24.0;
iconPlaceholder.Width = 24.0;
iconPlaceholder.Content = icon;
iconPlaceholder.Margin = new Thickness(3.0);
panel.Children.Add(iconPlaceholder);
button.Margin = new Thickness(0, 0, 3, 0);
button.Content = panel;
button.View = e.View;
button.Click += new RoutedEventHandler(NavigationButton_Click);
StackPanelContent.Children.Add(button);
_buttons.Add(button);
}
开发者ID:SignedUp,项目名称:omni-foundation,代码行数:28,代码来源:ViewNavigator.xaml.cs
示例19: PageAirportDistances
public PageAirportDistances(Airport airport)
{
this.Airport = airport;
InitializeComponent();
StackPanel panelAirports = new StackPanel();
panelAirports.Margin = new Thickness(0, 10, 50, 0);
ContentControl lblHeader = new ContentControl();
lblHeader.ContentTemplate = this.Resources["AirportsHeader"] as DataTemplate;
panelAirports.Children.Add(lblHeader);
ListBox lbAirport = new ListBox();
lbAirport.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbAirport.ItemTemplate = this.Resources["AirportItem"] as DataTemplate;
lbAirport.MaxHeight = GraphicsHelpers.GetContentHeight() - 100;
var airports = GameObject.GetInstance().HumanAirline.Airports.FindAll(a=>a!=this.Airport).OrderBy(a=>MathHelpers.GetDistance(a,this.Airport));
foreach (Airport destAirport in airports )
lbAirport.Items.Add(new KeyValuePair<Airport,Airport>(this.Airport,destAirport));
panelAirports.Children.Add(lbAirport);
this.Content = panelAirports;
}
开发者ID:rhgtvcx,项目名称:tap-desktop,代码行数:27,代码来源:PageAirportDistances.xaml.cs
示例20: GetNewMessagesNotificationOverlay
public static ImageSource GetNewMessagesNotificationOverlay(Window window, DataTemplate template, int count = 0)
{
if (window == null)
return null;
var presentation = PresentationSource.FromVisual(window);
if (presentation == null)
return null;
Matrix m = presentation.CompositionTarget.TransformToDevice;
double dx = m.M11;
double dy = m.M22;
double iconWidth = 16.0 * dx;
double iconHeight = 16.0 * dy;
string countText = count.ToString();
RenderTargetBitmap bmp = new RenderTargetBitmap((int) iconWidth, (int) iconHeight, 96, 96, PixelFormats.Default);
ContentControl root = new ContentControl
{
ContentTemplate = template,
Content = count > 99 ? "…" : countText
};
root.Arrange(new Rect(0, 0, iconWidth, iconHeight));
bmp.Render(root);
return bmp;
}
开发者ID:kveretennicov,项目名称:kato,代码行数:31,代码来源:Taskbarhelper.cs
注:本文中的System.Windows.Controls.ContentControl类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论