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

The Easy Shortcut Way Too Write....

$
0
0

Good Evening,

I have some things want to do it but...

i don't know how to solve this way

Example:

I have a A Label

I have a B Label

I have a C Label

If A or B or C have "error" word.

After Button Click"MessageBox.Show(You have some error)"

Else

{

"MessageBox.Show(register successful )"

}

How to write it this way? Did Any want know about it??


Junior C Sharp WPF


Missing TouchUpEvent on RepeatButton

$
0
0

I have a WPF application such that there is a modal Window with a RepeatButton. When a limit is reached, a Dialog Window is displayed. Using the keyboard, mouse, or Stylus this works as expected. However when touch is used to change the value via the RepeatButton that results in the Dialog Window, after closing the Dialog Window, any touch of the application causes a Click event on the RepeatButton. In delving into the problem, I can see that a TouchUp event never occurs, likely interrupted by the Dialog Window.  In the Dialog Window I handle TouchUp and TouchDown, but even if I do not set e.Handled = true, the error occurs.

Note:  It does not matter if touch is used for the Dialog Window.  The problem occurs when touch is used on the RepeatButton. 

Does anyone have any ideas on how to solve this issue?




WPF Dead or Not?

$
0
0

We've seen all the postings about WPF being Dead.  We heard from MSFT it was not, and they were starting to work on it again.  It's now about two years later and we see next to nothing regarding progress in WPF.   WPF was cutting edge technology and MVVM was "borrowed" by Angular to do client side binding very similar to what we already did with MVVM.  C'mon MSFT "Get Going"...  You're inaction is speaking loudly to us WPF adopters.

Should MSFT open source WPF being that they are unwilling to move it forward? 

Or should MSFT put a real plan together and let us know what's going on.  

Or is MSFT saying to us Typescript is the future and everything should be hosted in a browser which they don't have for WPF (without airspace issues).  

Here's a suggestion for MSFT, give us real browser so that we want and choose to embed your browser rather than CEF (Chrome Embedded Framework).  

Problems with WPF and Web Browser

$
0
0

Hi, I have a problem to display a link in my own WebBrowser module :-(

I would like to display a route via Google Maps.
The call via your own browser (eg Internet Explorer) works perfectly.
But as soon as I get the same call in its own WebBrowser I get an error that says that Internet Explorer may run in compatibility mode and that I should turn this off !?

Here is the Link:

http://maps.google.de/maps?f=d&saddr=An den Ruschen 27a 28816 Stuhr D &daddr=Borsteler Weg 36 27283 Verden D &t=p

Here is my small Mask:

<Window x:Class="RITRoute.MyWebBrowser"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Google-Maps, Browser" Height="768" Width="1028" Icon="Images/Riemke-it.JPG"
        Loaded="WinWebBrowser_Loaded"><Viewbox Stretch="Fill" StretchDirection="Both"><Grid  Height="768" Width="1024"><Grid.ColumnDefinitions><ColumnDefinition Width="*" /><ColumnDefinition Width="2*" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="Auto" MinHeight="22" /><RowDefinition Height="*" /><RowDefinition Height="Auto" MinHeight="22" /></Grid.RowDefinitions><TextBlock Text="Link:" HorizontalAlignment="Right" Height="22" VerticalAlignment="Top" Width="39.494" /><TextBox x:Name="txtInput" Background="Gold" Foreground="White" Grid.Row="0" Grid.Column="1" KeyDown="LinkEnter" /><WebBrowser x:Name="webOutput" Grid.Row="1" Grid.ColumnSpan="2" /><StackPanel Grid.Row="2" Grid.ColumnSpan="2" Orientation="Horizontal"><Button x:Name="btnHome2" Content="Riemke-IT" Click="btnHome2_Click" /></StackPanel><TextBox Height="21" Margin="0,0,43,0" Name="textBoxFehler" VerticalAlignment="Top" Focusable="False" Foreground="DarkRed" /></Grid></Viewbox></Window>

And the Call via C#:

            try
            {
                webOutput.Navigate(new Uri(MyLink));
            }
            catch
            {
                txtInput.Text = "http://www.";
                textBoxFehler.Text = "Wrong Adress!";
            }

Have anyone an idea how i can fix this?

Best Regards

Bernd

3D Effect for Button

$
0
0

This may be how I am asking Google, but I am having difficulty finding how to create a button that has a raised button effect.  Something like a traditional key on a physical keyboard.  

Any help is greatly appreciated.

 

Handwriting Recognition

$
0
0
I just bought a Surface Pro 4 and I'm having issues with the hand writing recognition. For one, I cannot "convert to text" or update my handwriting.  When I try to update the handwriting in my settings, it will not give me sentences to write, but only two blank lines instead. Has anyone had issues with this before?

Advice on performance with many controls and tabs

$
0
0

Hi WPF gurus,

I've only just begun working seriously in WPF and everything is working just fine. But that's the problem, I'm not sure if I should count that as "yeah, keep going like this."

Essentially I have an application that interfaces like a video game menu. You select one of many buttons to view another page and can go 'back'. This would have been a tab control in my winforms days but in WPF I've just marked elements as non-visible (hoping it would perform quickly and not render) as well as set the rendertransform.yproperty to +ActualHeight off the page. This way I can animate controls on the different views flying 'up' from the bottom of the screen, which is exactly what I'm trying to emulate.

All the animations have so far have been fluid and it's working great but I have about 100 controls. When all is done, it will be just under 1,000 so I'm wondering if this is even the right way to go about it. Is coding them on page 'load' an option?

I'm using some buttons which I override the template for and add my own animation for hoverover/out. I'm guessing buttons are more processing than a grid, border, or any other component so I might switch those out.

If this isn't enough information, I could upload a youtube video of it in action, some screenshots, or if it's allowed, I can give the dropbox link itself so you can run it.

Thanks in advance!

Adding dynamic tiles and columns in a grid

$
0
0

I have a grid of 4*4 rows and columns. I need a code for xaml.cs page lets for take example I take a variable where x=2,3,4,5,.... So at runtime when x=2 two tiles will be displayed in the grid, if x=3 three tiles will be displayed in the grid and accordingly if no. of tiles will be greater than 16 then a new column will get added into it.

Can anyone please write a small piece of code for this. Just the logical part..

Thanks!!!


How to set an word in center position of Richtextbox using WPF?

$
0
0

Hi,

I want to set word by word navigation i n richtextbox. I already done.But In that navigation,each word highlight in the left corner and the hide.But i want to highlight a word in center position of the richtextbox. So my query is,

1.How to get that top center position of the WPF Richtextbox and how to set words in that position?
2.How to set that current caret position into center top of the Richtextbox?

3.Any predefined API is there for setting a caret position in top center of the richtextbox? 

Regards

Sanju

Delay stop animation.

$
0
0
Hello. I have an animation that i start and stop. I need to prolong it a little bit more after stopping. Can we do in xaml somehow? Thanks in advance.

Exception swallowed that occured in direct binding property

$
0
0

I have a scenario where I bind a property to xaml. The property calls
some other layer code to get is enable value.

Sample code below.

public bool IsEnable
        {
            get { return GetIsEnableValue(); }
        }

        private bool GetIsEnableValue()
        {
            const int i = 1;
            var j = 1;

            if (i / j == 1)
            {
                throw new Exception();
            }

            // the exception thrown above is swallowed by WPF
            return false;
        }

I have observed that any exception that occurs within such a constellation would be swallowed by WPF and just cause a data binding error.

any idea what is the best way to implement such a scenario?

How to create a waterfall chart to display; time, frequency and amplitude (if possible)

$
0
0

I am new to C# and WPF. I am trying to create a waterfall display where the Y axis is time, the X axis is frequency and if possible change colour depending on amplitude. I currently have an ObservableCollection, I am displaying this in a DataGrid and using Binding to achieve this. Has anyone done something similar to this as I am stuck on how to start this! The time is in the collection so I wouldn't need to get system time or anything, I think I only need 3 parts of my collection but don't know how to acheive this.

Thanks in advance

Luke

how-to-move-a-grid-panel-in-wpf-window

$
0
0

how-to-move-a-grid-panel-in-wpf-window Its Working Slow

Point m_start;Vector m_startOffset;privatevoidGrid_MouseDown(object sender,MouseButtonEventArgs e){FrameworkElement element = sender asGrid;TranslateTransform translate = element.RenderTransformasTranslateTransform;

        m_start = e.GetPosition(gridHost);
        m_startOffset =newVector(translate.X, translate.Y);
        element.CaptureMouse();}privatevoidGrid_MouseMove(object sender,MouseEventArgs e){FrameworkElement element = sender asGrid;TranslateTransform translate = element.RenderTransformasTranslateTransform;if(element.IsMouseCaptured){Vector offset =Point.Subtract(e.GetPosition(gridHost), m_start);

            translate.X = m_startOffset.X + offset.X;
            translate.Y = m_startOffset.Y + offset.Y;}}privatevoidGrid_MouseUp(object sender,MouseButtonEventArgs e){FrameworkElement element = sender asGrid;
        element.ReleaseMouseCapture();}


hitesh modani

Xamarin.forms-How to create a sub listview inside a listview with data binding?

$
0
0

Hello,

I want to bind an observable collection of a List of items something like ObservableCollection<List> with that xaml code:

publicclassYourViewModel{//This is for Parent ListprivateIList<ParentListClass> _parentItems;publicIList<ParentListClass>ParentItems{get{return _parentItems;}set{ _parentItems = value;}}}publicclassParentListClass{publicstringParentTitle{get;set;}//This is for child ListpublicIList<ChildListClass>ChildItems{get;set;}}publicclassChildListClass{publicstringChildTitle{get;set;}publicstringChildSubTitle{get;set;}}

< ListView RowHeight="160" ItemsSource="{Binding ParentItem,Mode=TwoWay}" SeparatorVisibility="None" BackgroundColor="#F2F6F8" HorizontalOptions="Start">

<ListView.ItemTemplate>

<StackLayoutPadding="10"><StackLayoutOrientation="Horizontal"BackgroundColor="#ffffff"Padding="10"HorizontalOptions="FillAndExpand"><BoxViewWidthRequest="2"BackgroundColor="#D7D7D7"></BoxView><StackLayoutOrientation="Vertical"HorizontalOptions="FillAndExpand"VerticalOptions="FillAndExpand"><ListViewRowHeight="160"BackgroundColor="#ffffff"ItemsSource="{Binding 
ChildItems,Mode=TwoWay}"SeparatorVisibility="None"HorizontalOptions="FillAndExpand">
<ListView.ItemTemplate><DataTemplate><ViewCell><StackLayoutOrientation="Vertical"HorizontalOptions="FillAndExpand"VerticalOptions="FillAndExpand"><ButtonText="{Binding Value}"BackgroundColor="#ffff00"/></StackLayout></ViewCell></DataTemplate></ListView.ItemTemplate></ListView>

But my issue is ,main list view is listing but in each cell of main list view only first element of sublistview is listing.

Could anyone help to solve this?

Can I use SQLite for EntityFramework approved Microsoft way for WPF?

$
0
0
Now I use MS SQL but I want for some project use SQLite. I know there is Entity Framework Core 1 has support Code First for SQLite. But currently EF only supports SQLite on UWP. I found a few solution:

- https://github.com/msallin/SQLiteCodeFirst
- https://github.com/ExtCore/ExtCore

But they have little downloads to trust them. Is there a recommended Microsoft way to use SQLite for EF (with Code First) in WPF project?

Best way to implement Context Menu icons dynamically.

$
0
0

Hello,

I have this curious case where I am implementing a context-menu in WPF. Inline with MVVM I am building the context menu in the code and binding it to the XAML.

For every menu item of the context menu I have an icon. So in the code I have a switch case and looping etc and it works for now.

But I have to display additional information for the menu item in some cases. for example few of the menu items are special cases and I want to display like a blue dot or another small icon on top of the existing icon. Something like how a small icon appears on a large icon in one corner. Not sure how I can do this as I don't want to draw this small icon on every icon there is and then make it visible or hide it. I wan to achieve this is the best possible way.

Thank you.


Please Mark as Answered If this answers your question OrUnMark as Answered if it did not.
Happy to Help :)
My Site

Transforme xaml + vm to xaml.

$
0
0

Hi,

I have (actually I haven't, but i'm going to create) a xaml file and a datacontext that feeds some fields (eg. an itemscontrol, with a heterogeneous list of viewmodels). 

I would like, to transform these two files into one.

Eg:

<listbox><listbox.template><datatemplate><border background="yellow"><textblock text={binding name} /></border></datatemplate></listbox.template></listbox>

..fed with 3 objects with a name, would give: 

<listbox><listboxitem><border background="yellow"><textblock text="john" /></border><listboxitem><listboxitem><border background="yellow"><textblock text="jack" /></border><listboxitem><listboxitem><border background="yellow"><textblock text="jim" /></border><listboxitem></listbox>

... or at least the code representing the visual tree that is actually displayed.

Do you see some way to do that using standard method (I don't want to manage a handmade xslt)  ?

Thank you in advance for any help.


Can i set the background of a DataGrid to transparent?

$
0
0

I have tried everything I can think of. Is there a straightforward way to do this? I tried setting background to no brush, created a transparent bruch and set it to that, set the opacity to zero. Nothing works.

Thanks in advance!

Displaying bookmarks into tree view

$
0
0

I am working on populating the pdf’s bookmark and displaying it into a Tree View.

This is the bookmark:

I have converted those bookmarks into xml, I am using a third party dll i.e. itextsharp in it and now just have to display it into tree view.

Here is the xml format:

My designer code or the xaml code:

<Window.Resources>

    <HierarchicalDataTemplate x:Key="NodeTemplate"

           ItemsSource="{Binding XPath=./*}">

           <TextBlock x:Name="nodetext"/>

           <HierarchicalDataTemplate.Triggers>

               <DataTrigger Binding="{Binding Path=NodeType}"

                   Value="Element">

                   <Setter TargetName="nodetext" Property="Text"

                       Value="{Binding Path=Name}" />

               </DataTrigger>

           </HierarchicalDataTemplate.Triggers>

       </HierarchicalDataTemplate>

    </Window.Resources>

    <Grid>

       <Grid.RowDefinitions>

           <RowDefinition />

           <RowDefinition Height="Auto" />

       </Grid.RowDefinitions>

       <TreeView Name="trvItems">

         <TreeView.ItemTemplate>

             <HierarchicalDataTemplate ItemsSource="{Binding}">

                   <HierarchicalDataTemplate.ItemTemplate>

                       <HierarchicalDataTemplate ItemsSource="{Binding Title}">

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

                       </HierarchicalDataTemplate>

                   </HierarchicalDataTemplate.ItemTemplate>

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

               </HierarchicalDataTemplate>

           </TreeView.ItemTemplate>

       </TreeView>

My xaml.cs code:

string filename = System.AppDomain.CurrentDomain.BaseDirectory;

            filename =@"E:\test.pdf";

           string outputbookmark =@"E:\Tree Grid\Tree Grid\bin\Debug\HA.xml";

           var Sbytes =File.ReadAllBytes(filename);

           PdfReader pdfReader =newPdfReader(Sbytes);

           IList<Dictionary<string,object>> bookmarks =SimpleBookmark.GetBookmark(pdfReader);

           using (StreamWriter Sw = newStreamWriter(outputbookmark))

            {

               SimpleBookmark.ExportToXML(bookmarks, Sw,"ISO8859-1",true);

            }

           var bookmark =XmlParser<Bookmark>.Deserialize(outputbookmark);

         

            trvItems.DataContext = bookmark;

I am getting all the bookmarks here now what to do to display it into tree view properly.


Disable few items in the DataGridComboBoxColum and also want to disallow/block selection of disabled items

$
0
0

I would like to disable few items in theDataGridComboBoxColum and also want to disallow/block selection of disabled items.

How to achieve this functionalityusing MVVM in WPF?

Viewing all 18858 articles
Browse latest View live