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

RichTextBox input lag

$
0
0

Is there an option I'm missing? I create a brand new WPF project, using .NET 4.5.1, and add one RichtTextBox to it, start and type a couple of words. And as I type, I notice that letters don't appear immediately.. there is a constant lag in the noticeable range (so somewhere between 50 and 100 ms) which is highly distracting. It feels like you're on a remote desktop over a slow line.

Note that I'm just typing text myself, I'm not loading any large documents and there's never more than perhaps 4 lines of text in the box)

Here's my basic XAML

<Window x:Class="RtfTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"><Grid><RichTextBox HorizontalAlignment="Left" Height="207" Margin="10,19,0,0" VerticalAlignment="Top" Width="482"><FlowDocument><Paragraph><Run Text="RichTextBox"/></Paragraph></FlowDocument></RichTextBox></Grid></Window>

I have a hard time imagining MS would release something that can't be made to work properly so I guess I'm missing a flag or two - then again, the number of results you get searching for this issue and the lack of answers worries me.


How to call closed event

$
0
0

Hello,

Currently I am opening new wpf window from GetClientForPayment.xaml window :

UserList userList = new UserList(LName);
                        userList.Closed += UserList_Closed;

userList.ShowDialog();

private void UserList_Closed(object sender, EventArgs e)
        {
            //This method not working
        }

But when i closed UserList.xaml window Closed event not working.

Please guide what i am doing wrong.




How do I change dynamically a background color of a WPF:s button

$
0
0

Goal:
Change dynamically the button's background color inside of my customized private function. The start point is

gridMain.Children.

Problem:
I tried googling and I read about class button and lots of different website but I cannot find a relevant clue in order to change the background color. My way of thinking is that the concept will be same as nhibernate's ability to edit data and then save it.

I need to retrieve a specific button from gridMain.Children. that has a name, btn_test, and change the background color and then to be saved.

Again, the problem is that I cannot find a relevant code to my purpose.

Info:
- I'm using VS 2013 with WPF and C#.
- Inside of gridMain.Children. I have a lot of button with different name. Buttons are created dynamically.

Publishing ClickOnce Programmatically

$
0
0
I have multiple ClickOnce applications that need to be deployed to several different sites (QA and multiple production sites). I am working on a project that can publish all of these ClickOnce applications at once but I have not been able to find any descent documentation or examples. I want to use .NET 4.5. I know I need to use ProjectCollection but that's about all I know. 

WPF application

$
0
0
How to create intellisense to textbox with values from database. Also i need to make a billing application for which as i enter details n textbox it should form a billing type table. could anyone help me on the coding.

How to fire mouseup event from code?

$
0
0

I have a Grid "grid" and I would like to fire "MouseUp" event from code (without using the mouse device). I've tried to use 'RaiseEvent' but I got stuck.

Any help will be greatly appreciated.

how to make the textbox text to disappear on click

$
0
0

Hi,

I am using .NET framework 4.5,

I created WPF Login form, there is a default text in the text box ("User name"), and I want that this text ("User name") will disappear when the user is clicking on the textbox. There is no "click" event for textbox and i have already tried "MouseLeftButtonDown" but it didn't work.

any suggestion?

Keyboard Input of UserControl

$
0
0

I have design a user control, which processes lots of keyboard inputs. So I add the PreviewKeyDown Event handler in the user control, set the focusable property of the control to 'true' and call ' Keyboard.Focus(this)' in when needed. This does work but it leads to another problem. The user control's edge becomes visible. Only when I right click on the canvas of the main window and my contextmenu pops up, will the edge of the user control become invisible again. How can I avoid this edge or Can I implement my function in other ways?

I am using C#. Any advice will be appreciated.






how to convert path and vector to bitmap render performance?

$
0
0

hi,

i want to render this template with bitmap rendering and no vector rendering:

<Style TargetType="Label" x:Key="AccountLogin2_Style"><Setter Property="Template"><Setter.Value><ControlTemplate><Viewbox Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"><Grid ><Path Fill="{TemplateBinding Foreground}" Data=" M 105.36 17.41 C 114.91 6.34 129.76 1.66 143.97 0.97 C 157.73 0.27 172.28 1.45 184.45 8.48 C 197.04 15.65 204.80 29.15 207.86 43.00 C 209.43 52.59 208.35 62.33 208.10 71.98 C 207.66 82.33 208.71 92.78 206.98 103.05 C 205.89 110.09 202.75 116.55 200.15 123.12 C 194.43 136.58 188.31 150.24 178.46 161.26 C 196.38 164.50 213.58 170.95 229.72 179.29 C 240.48 184.70 250.70 191.13 261.53 196.40 C 270.44 200.40 279.22 204.95 286.79 211.20 C 293.52 216.84 299.93 224.07 301.00 233.14 L 301.00 263.00 L 0.63 263.00 C 0.61 253.34 0.64 243.68 0.61 234.02 C 0.45 227.84 4.00 222.39 7.80 217.82 C 15.27 209.27 25.21 203.33 35.36 198.51 C 47.56 193.06 58.82 185.79 70.71 179.74 C 86.91 171.31 104.17 164.70 122.17 161.38 C 110.21 147.84 103.66 130.68 96.92 114.19 C 92.26 103.41 92.61 91.45 92.69 79.95 C 92.81 70.95 91.93 61.97 92.01 52.97 C 91.81 40.01 97.03 27.22 105.36 17.41 Z" /></Grid></Viewbox></ControlTemplate></Setter.Value></Setter></Style>

Make TextBlock Visible Based on ComboBox selected index

$
0
0
How do I make a TextBlock hidden if nothing is selected in a ComboBox using XAML ?

Peter

Ivalueconverter

$
0
0

I'm new to WPF, not sure how to solve this.

I have two tables in my Sql server database. TableX and TableY. TableX has field ID(int), FirstName, LastName, Email. TableY has field PID(int), Roles. PID is foreign key to ID.

I'm trying to parse the values of FirstName and LastName to be displayed in a datagrid as PID. below is the XAML code I have:

'This is a template to store both FirstName and lastName which will be displayed in a combobox'

<Application.Resources>

       <DataTemplate x:Key="myTemplate">

           <WrapPanel HorizontalAlignment="Stretch">

               <TextBlock Text="{Binding FirstName}"/>

               <Label />

               <TextBlock Text="{Binding LastName}"/>

           </WrapPanel>

       </DataTemplate>

</Application.Resources>

'This is the combobox which is bound to the ItemTemplate'

<ComboBox Height="23" HorizontalAlignment="Right" Margin="0,90,267,0" Name="ComboID" ItemsSource="{Binding}" VerticalAlignment="Top" Width="208" ItemTemplate="{StaticResource myTemplate}" />

How can I display PID from TableY in a datagrid when I select the persons' name from the comboBox?

Below is the datagrid

<DataGridTemplateColumn x:Name="pIDColumn" Header="Person ID" Width="auto">

       <DataGridTemplateColumn.CellTemplate>

            <DataTemplate>

              <TextBlock Text="{Binding Path=PID}"/>   

          </DataTemplate>

     </DataGridTemplateColumn.CellTemplate>                        </DataGridTemplateColumn>

                              


                                      

WPF - Combobox Selected Item Binding issue

$
0
0

Hi, I am new to WPF MVVM. I am currently facing some difficulties in implementing selectionchanged event for a Combobox using MVVM. I have tried to implement various solutions to this issue as posted in various websites, but still am not able to figure out the issue. Hence I am posting the whole code below.

Scenario- On selecting books from the combobox, "Do your task with books" should appear in a messagebox.

Model - Product.cs

 class Product:INotifyPropertyChanged
    {
        private string _product;
        public string _prod
        {
            get
            {
                return _product;
            }
            set
            {
                _product = value;
                OnPropertyChanged("_prod");
                if (_product == "Books")
                {
                    System.Windows.MessageBox.Show("Do your Task with " + value);
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string val)
        
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(val));
            }
        }
    }

ViewModel -

class ViewProduct
    {
        public IList <Product> _vProd;
        public ViewProduct()
        {
            _vProd = new ObservableCollection<Product> { new Product { _prod = "Books" }, new Product { _prod = "Sports Kit" }, new Product { _prod = "Charts" } };
        }

        public IList<Product> Products
        {
            get
            {
                return _vProd;
            }
            set
            {
                _vProd = value;
            }
        }

    }

View- MainWindow.xaml

<Grid><ComboBox Width="100" Height="25" Name="cmBox" ItemsSource="{Binding Products}" IsSynchronizedWithCurrentItem="True" DisplayMemberPath="_prod" SelectedItem="{Binding _prod,Mode=TwoWay}"></ComboBox></Grid>

App.xaml.cs

 public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            MainWindow mw = new MainWindow();
            ViewProduct vw = new ViewProduct();
            mw.DataContext = vw;
            mw.Show();
        }
    }

Could somebody please help me sort out this problem?

Thanks,



sujan_1989

MediaElement failing with {"Exception from HRESULT: 0xC00D11B1"}

$
0
0

On some movies MediaElement is failing for me with exception in %subj%. Google does not have a lot of info about HRESULT 0xC00D11B1, but it I guessed it is some problem with codecs. However, contrary to what I read everywhere, Windows Media Player is able to play those movies without any problem.

 

What can be preventing MediaElement from playing those movies as well? How should I go about diagnosing such a problem and tracking its source? I've looked everywhere (even into system event log), but found nothing, so the only clue I have is that exception mentioned in %subj% catched in handler of MediaFailed event of MediaElement.

 

Thanks, M.

Can't add x:Name property

$
0
0

I am writing WPF application and some how I cannot set x:Name property to one UserControl.

This user control is stored in the startup project but its base clase is from other assembly.

And averythink is OK when this UC has no name.

But after x:Name property is set I get compiler error.

The type or namespace name 'AAA' does not exist in the namespace 'BBB' (are you missing an assembly reference?)

This is strange for me how it is even possible.

Is there somebody who can explain this and tell how to fix?

I found this bug on this link but I dont like the solution

texbox fomat?

$
0
0
                
I want to write in textbox with hex format automatically, not like this HHGGFF554R but something like this GG HH FF 55 4R
How can I do this?Thank


WPF textbox not able to type anything when open up the 3rd window

$
0
0

Hi,

I have created 2 project

i) Window Form Application

ii) WPF Application

under window Form Application there is a form; named: Form1

Under WPF Application there are 2 forms; named: WPFWindow1 andWPFWindow2

The scenario will be:

Window Application

1) Form1 startup with  button1,

2) Form1's Button click, WPFWindow1 open up.

WPF Application

1) WPFWindow1 contain button2,

2) WPFWindow1's Button click, WPFWindow2 open up.

3) WPFWindow2 contain textbox1 for entry.

Sequence:-

Form1 --> WPFWindow1 --> WPFWindow2-->Textbox

Problem:

- the textbox in WPFWindow2 is not accepting any keyboard input except space bar & backspace.

I have include ElementHost.EnableModelessKeyboardInterop in Form1 ,and WPFWindow1's textbox is able to accept keyboard input, the problem only occurs on the 2nd window(WPFWindow2) which is call up from WPFWindow1 .

When I swap the sequence of WPFWindow2 to WPFWindow1, the textbox in WPFWindow2 is working fine, so I assume it's not the problem with WPFWindow2.

Any1 can help?

Thanks.

Regards,

Kong CA

Why does the behaviour of a derived DataGrid Class differ?

$
0
0

Hello together,

I would like to reuse xaml code in my wpf application. I have multiple classes, which are always using an array of a struct (X,Y,Z-coordinates). Therefore, I added a new datagrid class deriving from the datagrid built-in class. All I want to do is to change the DataContext of my Datagrid, which is showing a collection of a struct I am converting with my custom converter.

On top is a TreeView which uses a datatemplateselector.

If I have following Template:

<DataTemplate x:Key="bspline"><TreeViewItem Header="B-Spline"><TreeViewItem Header="Knot Points" IsExpanded="True"><DataGrid ItemsSource="{Binding Path=KnotPoints, Converter={StaticResource geoArrayToDataGrid}}"
            AutoGenerateColumns="False"><DataGrid.RowHeaderTemplate><DataTemplate><TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, 
                                AncestorType={x:Type DataGridRow}}, 
                                Path=Item.Num,diag:PresentationTraceSources.TraceLevel=High}"/></DataTemplate></DataGrid.RowHeaderTemplate><DataGrid.Columns><DataGridTextColumn Header="X" Binding="{Binding X}"/><DataGridTextColumn Header="Y" Binding="{Binding Y}"/><DataGridTextColumn Header="Z" Binding="{Binding Z}"/></DataGrid.Columns></DataGrid></TreeViewItem><TreeViewItem Header="Through Points" IsExpanded="True" Visibility="{Binding Path=ThroughPoint, Converter={StaticResource nullTovisibility}}"><y:MultiGeoStruct AutoGenerateColumns="False" ItemsSource="{Binding Path=ThroughPoint, Converter={StaticResource geoArrayToDataGrid}}"/></TreeViewItem><ComboBox Text="Mode" SelectedIndex="{Binding IsClosed}"><TextBlock Text="Open"/><TextBlock Text="Closed"/></ComboBox></TreeViewItem></DataTemplate>

the KnotPoints are displayed as intended (DGV with x,y,z and as rowheader the list number). My ThroughPoints are similar, but they are not displayed. I derived my class form datagrid and the template is identical (see below). I played around a bit using DataContext, but I cannot see, why my control's behaviour differs from the behaviour of the common DataGrid. As the datacontext should be inherited I canot see, why my code does not work. Extended debug information did not give any hint where the problem can be.

Thanks for your help in advance.

Code of my custom control:

<DataGrid x:Class="FlexForCFK.CAD.Controls.MultiGeoStruct"
             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:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"><DataGrid.RowHeaderTemplate><DataTemplate><TextBlock Text="{Binding Item.Num,RelativeSource={RelativeSource Mode=FindAncestor,
                                      AncestorType={x:Type DataGridRow}}}"/></DataTemplate></DataGrid.RowHeaderTemplate><DataGrid.Columns><DataGridTextColumn Header="X" Binding="{Binding X, diag:PresentationTraceSources.TraceLevel=High}"/><DataGridTextColumn Header="Y" Binding="{Binding Y, diag:PresentationTraceSources.TraceLevel=High}"/><DataGridTextColumn Header="Z" Binding="{Binding Z, diag:PresentationTraceSources.TraceLevel=High}"/></DataGrid.Columns></DataGrid>

Change Row Background as soon I make DataGrid.Items.Add(new Item() { FlagE = status, DtUpdate = wdtupd........

$
0
0

For visual reasons I am adding  rows to a wpf datagrid by using   "datagrid.Items.Add(new Item() { FlagE = status, DtUpdate = wdtupd"............I have triggers in xaml, but for some reason ( not using datagrid.ItemsSouce, perhaps?), they are not fired.

I am an amateur programmer, so pardon if this a basic question!

<Style TargetType="DataGridRow">
<Setter Property="Background" Value="LightBlue"/>
<Style.Triggers>
<DataTrigger Binding="{Binding FlagE}" Value="1">
<Setter Property="Background" Value="LightBlue"/>
</DataTrigger>
<DataTrigger Binding="{Binding FlagE}" Value="2">
<Setter Property="Background" Value="YellowGreen"/>
</DataTrigger>
<DataTrigger Binding="{Binding FlagE}" Value="3">
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>

and the data column

<DataGrid.Columns>
                <DataGridTextColumn
                Header="Flag"
                Width="120"
                Binding="{Binding FlagE}" >
                    <DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="TextBox">
                            <Setter Property="Foreground" Value="Blue"/>
                        </Style>
                    </DataGridTextColumn.EditingElementStyle>
                </DataGridTextColumn>

..


           

</Style>

Could not find file 'C:\Users\User\AppData\Local\Temp\Test.exe.manifest'.

$
0
0

When I run my wpf browser application in visual studio and open it in IE it work OK but when I load it to the server and run it I get this error and I don't know why

PLATFORM VERSION INFO
    Windows             : 6.1.7601.65536 (Win32NT)
    Common Language Runtime     : 4.0.30319.18444
    System.Deployment.dll         : 4.0.30319.18408 built by: FX451RTMGREL
    clr.dll             : 4.0.30319.18444 built by: FX451RTMGDR
    dfdll.dll             : 4.0.30319.18408 built by: FX451RTMGREL
    dfshim.dll             : 4.0.41209.0 (Main.041209-0000)

SOURCES
    Deployment url            : file:///C:/Users/User/AppData/Local/Temp/Test-4.xbap

IDENTITIES
    Deployment Identity        : Test.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6fb93d1c7c91095f, processorArchitecture=msil

APPLICATION SUMMARY
    * Online only application.

ERROR SUMMARY
    Below is a summary of the errors, details of these errors are listed later in the log.
    * An exception occurred while downloading the manifest. Following failure messages were detected:
        + Downloading file:///C:/Users/User/AppData/Local/Temp/Test.exe.manifest did not succeed.
        + Could not find file 'C:\Users\User\AppData\Local\Temp\Test.exe.manifest'.
        + Could not find file 'C:\Users\User\AppData\Local\Temp\Test.exe.manifest'.
        + Could not find file 'C:\Users\User\AppData\Local\Temp\Test.exe.manifest'.

COMPONENT STORE TRANSACTION FAILURE SUMMARY
    No transaction error was detected.

WARNINGS
    There were no warnings during this operation.

OPERATION PROGRESS STATUS
    No phase information is available.

ERROR DETAILS
    Following errors were detected during this operation.
    * [06/05/2014 23:51:28] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
        - Downloading file:///C:/Users/User/AppData/Local/Temp/Test.exe.manifest did not succeed.
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
            at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
            at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
            at System.Deployment.Application.DownloadManager.DownloadManifestAsRawFile(Uri& sourceUri, String targetPath, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
            at System.Deployment.Application.DownloadManager.DownloadApplicationManifest(AssemblyManifest deploymentManifest, String targetDir, Uri deploymentUri, IDownloadNotification notification, DownloadOptions options, Uri& appSourceUri, String& appManifestPath)
            at System.Deployment.Application.DeploymentManager.BindCore(Boolean blocking, TempFile& tempDeploy, TempDirectory& tempAppDir, FileStream& refTransaction, String& productName)
            at System.Deployment.Application.DeploymentManager.BindAsyncWorker()
        --- Inner Exception ---
        System.Net.WebException
        - Could not find file 'C:\Users\User\AppData\Local\Temp\Test.exe.manifest'.
        - Source: System
        - Stack trace:
            at System.Net.FileWebRequest.EndGetResponse(IAsyncResult asyncResult)
            at System.Net.FileWebRequest.GetResponse()
            at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
        --- Inner Exception ---
        System.Net.WebException
        - Could not find file 'C:\Users\User\AppData\Local\Temp\Test.exe.manifest'.
        - Source: System
        - Stack trace:
            at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)
            at System.Net.FileWebRequest.GetResponseCallback(Object state)
        --- Inner Exception ---
        System.IO.FileNotFoundException
        - Could not find file 'C:\Users\User\AppData\Local\Temp\Test.exe.manifest'.
        - Source: mscorlib
        - Stack trace:
            at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
            at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
            at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
            at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
            at System.Net.FileWebStream..ctor(FileWebRequest request, String path, FileMode mode, FileAccess access, FileShare sharing, Int32 length, Boolean async)
            at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)

COMPONENT STORE TRANSACTION DETAILS
    No transaction information is available.

Thanks

How Do I Write Back to a JSON using VB? SampleData.json in SplitPage Example

$
0
0

Ok, I'm trying to grasp the JSON aspect to the example application. I figured out the binding aspect, but now what I want to do is to put a TextBox on the view, bind it to the SampleData.json in the example data, and then have that text box update the JSON data.

I have got the textbox to display the data, but I cannot figure out how to write-back to the file.   If someone can get me started on this I would appreciate any assistance.  Also, I want to do this in VB/XAML, not C or JavaScript.

Thanks everyone for reviewing this.

Viewing all 18858 articles
Browse latest View live