DataGridTextColumn WrapText
Problem opening a WPF window directly in front of its winform owner on a dual monitor system
I am using the following code to make a winform the owner of a WPF window displayed as a dialog:
WindowInteropHelper helper = new WindowInteropHelper(window);
helper.Owner = winForm.Handle;
I am doing this, because I want the dialog to be displayed directly in front of its winform owner.
My problem occurs when I open our winforms application on, say, monitor 2 of a dual monitor system, and, then, move the application to monitor 1.
When I open the WPF window from our app - now on monitor 1 - the WPF window, still, appears on monitor 2.
I have tried setting the WPF window's WindowStartupLocation to WindowStartupLocation.CenterOwner, but that doesn't help.
Any insights into how to solve this problem would be appreciated.
Thanks,
rgr_brookline
rgr_brookline
Implementing Hit Testing for Strokes of InkCanvas
I've implemented a custom InkCanvas and multiple custom Strokes, which are described here: Custom Rendering Ink
Every thing works fine, except I can't do Hit Testing on my strokes.
At the "Implementing Custom Strokes" section of the above link, it says:
The Stroke class can also perform hit testing. You can also implement your own hit testing algorithm by overriding the HitTest method in the current class.
but i cant find any override-able version of HitTest method there!!!
Can anybody please help me implement hit testing on a custom stroke?
Thanks
WPF layout Template
WPF DatePicker SelectedDate Binding Format
Hi,
I am using WPF DatePicker Control which is bound to DateTime field. Now I used stringformat property of binding like below to specify dateformat :
<DatePicker SelectedDate="{Binding Path = SellStartDate, StringFormat = {}{0:dd-MM-yyyy}}"></DatePicker>
When I used the same stringformat with textblock or textbox it worked but not working in case of Datepicker.
I want to display date in dd-MM-yyyy format in datepicker when it bounds from datasource and when user selects a data from calendar.
Please let me know how can I achieve this. Thanks in advance.
Pratham
Setting a property of a usercontrol to a static resource...
I have some functionality in my project that, in the interest of speed, I just cut and pasted to the places I needed it. It's a bit of XAML and code that manages a document list. Now that I have a bit of time to focus on it, I'd like to encapsulate that bit into a usercontrol that I can drop in and replace the duplicated XAML and code.
One question I have... The control would have to use different colors for it's primary elements, depending on which area it is being used in. At the moment, I am just assigning the colors directly to the elements that need it via a static resource I have declared. How would I expose a property, from the user control, for the primary color to be used?
Do I create the property in the code-behind of the usercontrol and then assign it in the XAML where it's used? And if so, how do I do that with a static resource?
Thanks.
J
http://digitalcamel.blogspot.com/
How to Fix the Resolution of MainWindow and Stretch on Maximized WindowState
WPF Control Background Image Change Delay
Hi. I have a WPF application that takes a screenshot of the contents of a WindowsFormsHost control and applies it to the background of a Grid control. The Grid acts as a transition screen from the WindowsFormsHost to other WPF controls. This is done to make a smooth transition effect and to avoid air space issues. I first capture the WinFormsHost control image as a bitmap and apply it to the Grid background. Then programmatically change the visibility of the transition Grid to visible. Then do an opacity animation to smoothly show another control. It works perfectly about 70 to 90 percent of the time depending on what computer I test the application on. The problem is that the transition Grid background is not being rendered fast enough or at the correct time. So that occasionally I am seeing a screenshot from a previous transition which does not match the current screen image at transition time.
If I could somehow ensure that the transition image was drawn before the Grid is made visible, it would work everytime. I just cannot see how to do this. The application seems to always wait until the last minute to do any rendering.
I have tried to force rendering with Dispatcher.Invoke() and Dispatcher.BeginInvoke() methods. I have also tried to delay the time when the Grid is made visible with a Dispatcher Timer, but no matter how much time there is between the call setting the background image and setting the visibility, the Grid does not always update. I have also tried things like InvalidateVisual() with no luck.
DataGridComboBoxColumn
I have class Woker
public class Worker
{
public int WorkerId { get; set; }
public string Name { get; set; }
static public List<Worker> DefaultWorker()
{
return new List<Worker> {
new Worker {Name="Аношко Марина" },
new Worker {Name="Уланов Константин" }
}}
and class Task
public class Task{
public int TaskId { get; set; }
public Worker Responsible { get; set; }
}
My DataGrid..ItemsSource contain List<Task>
I wont binding Woker whith DataGridComboBoxColumn
var dc4 = new DataGridComboBoxColumn { Header = "Responsible", ItemsSource = Worker.DefaultWorker(), SelectedItemBinding = new Binding("Responsible") };
DataGrid.Columns.Add(dc4);
But see this
Help me please
DataGrid
I have Some class
public class Enterprise
{
public int EnterpriseID { get; set; }
public string Title { get; set; }
}
I conect List of this class to DataGrid.ItemSourse=List<Enterprise>
In DataGrid I have 2 columns
var dc0 = new DataGridTextColumn() { Header = "№/№", Width = 50, IsReadOnly = true,Binding = new Binding(?????????) };
var dc1 = new DataGridTextColumn() { Header = "Title", Binding = new Binding("Title "), Width = DataGridLength.Auto, IsReadOnly = true };
I wont see number Row like
1 | BMW
2 | Opel
3 | Mersedes
But firs colunm NOT Id . Mast be number Row
How Write This On C#
<DataGridTextColumnHeader="Wrap"Binding="{Binding LongString}"Width="100"><DataGridTextColumn.ElementStyle><StyleTargetType="TextBlock"><SetterProperty="TextBlock.TextWrapping"Value="Wrap"/></Style></DataGridTextColumn.ElementStyle></DataGridTextColumn>
Wpf NumericDatagrid Column
Hai
I want to create Numeric text box in datagrid user control. I have created using below code andf it is working fine.
My problem is when I type grid numeric cell allows first key alphabet, then it restricts alphabet and allows only digits.
In WGrid XAML
<DataGrid x:Class="WpfGrid.WGrid" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:WpfGrid" mc:Ignorable="d" d:DesignHeight="300" Width="500" PreviewKeyDown="DataGrid_PreviewKeyDown" BeginningEdit="DataGrid_BeginningEdit" SelectionMode="Single" SelectionUnit="Cell" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" CanUserResizeColumns="False" EnableRowVirtualization="False"></DataGrid> namespace WpfGrid { public partial class WGrid : DataGrid { public WGrid() { InitializeComponent(); } } public class DataGridNumericColumn : DataGridTextColumn { protected override object PrepareCellForEdit(System.Windows.FrameworkElement editingElement, System.Windows.RoutedEventArgs editingEventArgs) { TextBox edit = editingElement as TextBox; edit.PreviewTextInput += OnPreviewTextInput; return base.PrepareCellForEdit(editingElement, editingEventArgs); } void OnPreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e) { e.Handled = new Regex("[^0-9.]").IsMatch(e.Text); } } }
After Creating this control I added this on a new WPF application
XAML
<Window x:Class="WpfGrid.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfGrid" mc:Ignorable="d" Title="MainWindow" Height="475" Width="785" Background="#FF45A7B8"><local:WGrid x:Name="Dgv" HorizontalAlignment="Left" Height="383" Margin="51,39,0,0" VerticalAlignment="Top" Width="674" DbfInsert="Dgv_DbfInsert" RowHeaderWidth="{DynamicResource {x:Static SystemParameters.CaretWidthKey}}" GotoGolumn="Dgv_GotoGolumn" ><local:WGrid.Columns><DataGridTextColumn Binding = "{Binding Path=Name}" ClipboardContentBinding = "{x:Null}" Header = "Name" Width = "200" /><local:DataGridNumericColumn Binding = "{Binding Path=Weight}" Header="Weight" Width = "100" /><DataGridTextColumn Binding = "{Binding Path=Amount}" ClipboardContentBinding = "{x:Null}" Header = "Amount" Width = "100" /></local:WGrid.Columns></local:WGrid></Window>
and in form
public partial class MainWindow : Window { ObservableCollection<Customer> collection = new ObservableCollection<Customer>(); public MainWindow() { InitializeComponent(); collection.Add(new Customer()); Dgv.ItemsSource = collection; } public class Customer { public string Name { get; set; } public Decimal Weight { get; set; } public Decimal Amount { get; set; } }
On running this DataGridNumericColumn allows first character alphabet after that it restricts.
Please tell me how to correct this problem. User Control name is WGrid.
Thanks.
programmer
WebBrowser
I have this Xaml
<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication4"
mc:Ignorable="d"
Title="MainWindow" Height="950" Width="925"
MouseDown="Window_MouseDown">
<StackPanel>
<TextBox x:Name="tb">robolab.by/</TextBox>
<Button Click="Button_Click">Нажми</Button>
<WebBrowser x:Name="Web"
Height="800"
MouseDown="Web_MouseDown"
Navigated="Web_Navigated"
Navigating="Web_Navigating"></WebBrowser>
</StackPanel>
</Window>
When I go to site and click to reference Vk. Open New Window Internet explorer
None of the events of the instructions in the WebBrowser does not intercept clicking on this link
QUESTION
1) how to intercept Click of this link??
2) How to block opening Enternet Explorer
Installing C++ MFC after the intial installation
I need to add C++ Microsoft Foundation Classes. I need it now but didn't specify it on the initial installation. How do I do it now so I can see the MFC templates.
Thanks
Guy Legere
wpf grdiview select all notworking
Hello friends,
This is designed in wpf . If you look at the bottom of the image there is a option for selecting all , When I click in select all all the row should be selected . How I can achieve
Custom DrawingBrush for Weather Fronts
Hello. I'm trying to use custom drawing brushes to be able to draw weather fronts (cold, warm, etc.). I've been able to, with much trial and error, get essentially what I want with a straight horizontal line for a warm front (red line with repeating half cicles). However, I don't know how to transform that in a way that it would work with vertical lines, paths, curves, etc.
Here's what I have so far...
<Line Height="235" Canvas.Left="834" Canvas.Top="294" Width="514" X1="0" Y1="150" X2="514" Y2="150" StrokeThickness="35" ClipToBounds="False"><Line.Stroke><DrawingBrush TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,100,80"><DrawingBrush.Drawing><DrawingGroup><GeometryDrawing Brush="blue"><GeometryDrawing.Geometry><GeometryGroup><LineGeometry StartPoint="0 -18.5" EndPoint="100 -18.5" /></GeometryGroup></GeometryDrawing.Geometry><GeometryDrawing.Pen><Pen Thickness="2"><Pen.Brush><SolidColorBrush Color="red" /></Pen.Brush></Pen></GeometryDrawing.Pen></GeometryDrawing><GeometryDrawing Brush="red"><GeometryDrawing.Geometry><!--<EllipseGeometry RadiusX="25" RadiusY="5" Center="35,10" />--><PathGeometry Figures="M 0 -10 Q 37.5 -15 75 -10" /></GeometryDrawing.Geometry></GeometryDrawing></DrawingGroup></DrawingBrush.Drawing></DrawingBrush></Line.Stroke></Line>
Which renders this:
But if I take that code and put in a path with a curve in it, the path renders like this:
I can understand why it does this, but I need to know how, or at least some clues, to transform the code so it looks properly regardless of the direction/shape of the line.
I should also note that while I am currently doing this in Xaml, I will eventually be doing this in code behind, but I can translate.
Thanks in advance,
Andrew
How to imply a wpf apps on lockscreen like cortana in win10
Hi, all
I have a WPF application, it works on win10, and I want to display it on lockscreen like Cortana.
How can I do ?
Thanks a lot!
WPF menu for system tray icon
TreeView navigation key "Up" stucks sometimes.
I'm using .net 4.0.
HOW TO RUN LIVE STREAMING IN WPF
Hi,
I want to get streaming using this live channel and want to show streaming in WPF application using VLC ActiveX Plug-in and IE Web Plugin v1. VLC is visible
on WPF but not showing streaming when i add this link to VLC.AddTarget Method.
Here is Channel Link : rtsp://livestreaming2.itworkscdn.net/squranlive/squran_360p
Is there any other way to get this steaming work in my progam ???
Can anyone help me in this Plz ?
Thanks
Jaa Zaib
Jazaib Hussain