Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all 18858 articles
Browse latest View live

DataGridTextColumn WrapText

$
0
0
How I can realize WrapText in DataGridTextColumn 

Problem opening a WPF window directly in front of its winform owner on a dual monitor system

$
0
0

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

$
0
0

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

$
0
0
Can someone let me know from where I can get a set of layouts for my WPF application, like the css templates that we get for Web applications?

WPF DatePicker SelectedDate Binding Format

$
0
0

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...

$
0
0

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

$
0
0
I would like to fix the resolution of my project and then stretch the window maximized to the entire screen.  I know that this is not normal for a WPF application, but because of performance issues I have to limit the resolution.  I have a main window with several controls and userControls.  I have tried to use Viewbox but am not sure I can implement it on the entire window.  Thanks.

WPF Control Background Image Change Delay

$
0
0

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

$
0
0

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

$
0
0

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#

$
0
0
<DataGridTextColumnHeader="Wrap"Binding="{Binding LongString}"Width="100"><DataGridTextColumn.ElementStyle><StyleTargetType="TextBlock"><SetterProperty="TextBlock.TextWrapping"Value="Wrap"/></Style></DataGridTextColumn.ElementStyle></DataGridTextColumn>

Wpf NumericDatagrid Column

$
0
0

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

$
0
0

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

$
0
0

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

$
0
0

  

   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

$
0
0

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

$
0
0

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

$
0
0
I am newbie to WPF and I am building simple application that will sit in sys tray and on mosue click will show context menu. Now what I want is to be able to show WPF menu which has all those nice features like having other controls in its menu items and and be able to do other fancy gui stuff. So how can I do this? I am using NotifyIcon class for tray icon which is WinForms based, but this class does not support WPF menus. Any ideas?

TreeView navigation key "Up" stucks sometimes.

$
0
0
Hello. For some reason sometimes Up key navigation stops working on an opened category. If I close it then I can go up again. Any ideas what can cause it? Down navigation and Page Up, Page Down are working well, btw.


I'm using .net 4.0.

HOW TO RUN LIVE STREAMING IN WPF

$
0
0

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

Viewing all 18858 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>