How to get instance of Panel that holds content of ItemsControl?

It’s a little tricky since you don’t know the name of the Panel so you can’t use FindName etc. This will work for most cases where an ItemsPresenter is present private Panel GetItemsPanel(DependencyObject itemsControl) { ItemsPresenter itemsPresenter = GetVisualChild<ItemsPresenter>(itemsControl); Panel itemsPanel = VisualTreeHelper.GetChild(itemsPresenter, 0) as Panel; return itemsPanel; } An implementation of GetVisualChild private static … Read more

What is the best way to simulate a Click with MouseUp & MouseDown events or otherwise?

I would use a Button control and overwrite the Button.Template to just show the content directly. <ControlTemplate x:Key=”ContentOnlyTemplate” TargetType=”{x:Type Button}”> <ContentPresenter /> </ControlTemplate> <Button Template=”{StaticResource ContentOnlyTemplate}”> <Label Content=”Test”/> </Button>

Is it appropriate to extend Control to provide consistently safe Invoke/BeginInvoke functionality?

You should create Begin and End extension methods as well. And if you use generics, you can make the call look a little nicer. public static class ControlExtensions { public static void InvokeEx<T>(this T @this, Action<T> action) where T : Control { if (@this.InvokeRequired) { @this.Invoke(action, new object[] { @this }); } else { if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)