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

We could really use an example of navigation for WPF apps, please

$
0
0
At my new job we're working on our first WPF app here. I think it likely that we'll adopt MVVM Light as the framework (toolkit) for doing our development. I've watched the Pluralsight course that Laurent put out on MVVM Light. It was good; in fact very good. But I'm sorry I'm still not getting navigation using locator. I could really use a concrete example app to see how its meant to be done.

Can someone please point me to an example?

Rod


call method of view model from view (xaml.cs)

$
0
0

I have a question on calling a method of view model from view (xaml.cs). Any suggestions would be appreciated.

The method works in view model since if I call the method in view model constructor, I will be able to see them data in DataGrid. But when I call the method in view (xaml.cs), the DataGrid in empty.

In the view part, I have the code snippet below: (xaml.cs part)

 private ShellViewModel viewModel = new ShellViewModel();

        public ShellView()

        {

            this.DataContext = viewModel;

            InitializeComponent();

        }

......

        private void Button_Click(object sender, RoutedEventArgs e)

        {

            viewModel.Init();

        }// @@cannot call this method successfully

WPF Treeview: count treeview items with specific tag

$
0
0

Hello,

I have a question that i need some help with,

I have a wpf treeview that is being populated programatically.

each treeviewitem has a tag: user, computer or folder

I would like to somehow to display number of treeviewitems that have "computer tag" beside the folder name. 

I am trying to walk a tree this way 

Private Sub walktree(ByVal n As TreeViewItem)
CompNumber = 0
        If n.Tag = "computer" Then
           CompNumber +=1
        End If
        If n.HasItems = True Then
            Dim aNode As TreeViewItem
            For Each aNode In n.Items
                walktree(aNode)
             textblock.text += aNode & "Folder (" & CompNumber & ")"
            Next
        End If
    End Sub

I know I am not getting this right, could you please suggest a correct way to count items with spesific tag? 

thank you

Update a window from another class/window

$
0
0

I have an application with a splash screen, that contains a progress bar.  My goal is to inject something like this into the code and have it update the progress bar as it passes each code segment (some segments can take a few seconds, others not so much):

Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => ((App)Application.Current).AppSplash.ProgressBarValue = 10));

Within the App class and the main window, I would be injecting the above code into functions as the function progresses each step.  

Within the App Class I have this

public IncredibleSplash AppSplash;

public App()
{
     DispatcherHelper.Initialize();
     AppSplash = new IncredibleSplash();
     AppSplash.ProgressBarValue = 0;
}

I then call the AppSplash.Show() as the first line item in the OnStartUp function.  

Within the property for ProgessBarValue, I have the following:

public int ProgressBarValue {
get { return pbValue; }
set
    {
      pbValue = value;
      pgbMain.Value = value;
    }
}

Run I run the app, the progress bar does not update as expected (updating by chunks), instead, it updates all at once at the end of the process.

If someone could point me in the right direction, that would be greatly appreciated.  


Robert Johnston

What tools that is used to detect WPF memory leak from Microsoft?

$
0
0

Hi,

What tools that is used to detect WPF memory leak from Microsoft? I got an WPF project, there's a lot of memory leak. How to fix it?

It is straightforward.

Thanks

Weera

TreeView - Drag & drop issue

$
0
0

Hello everybody,

I'm encountering an issue with a TreeView. I try to implement a drag & drop to enable moving items into this TreeView.

I implemented some events like this :

<TreeView><TreeView.Items><TreeViewItem Header="Root" IsExpanded="True" IsSelected="True" ItemsSource="{Binding Path=MyList}"
                              Padding="5"><TreeViewItem.ItemContainerStyle><Style TargetType="TreeViewItem"><EventSetter Event="Selected"
                                         Handler="TreeViewItem_Selected"/><EventSetter Event="Unselected"
                                         Handler="TreeViewItem_Unselected"/><EventSetter Event="DragOver"
                                         Handler="TreeViewItem_DragOver"/><EventSetter Event="DragLeave"
                                         Handler="TreeViewItem_DragLeave"/><EventSetter Event="Drop"
                                         Handler="TreeViewItem_Drop"/><Setter Property="AllowDrop" Value="True"/></Style></TreeViewItem.ItemContainerStyle></TreeViewItem></TreeView.Items></TreeView>

My problem is if when the events DragOver or Drop are fired for a TreeViewItem, all parent nodes fire them too.

For example, I have :

Root
> US
>>California
>>>LosAngeles

If I drop an item on LosAngeles, the events are fired by LosAngeles and California and US ...

Do you know how I could avoid having this behavior on parent nodes ?

Thanks in advance for your suggestions.

How to remove history/navigation from a WPF Frame

$
0
0
Hello,


i have a WPF Window, and on pressing Button A i want to display some content in a certain area of my window.
when pressing "Button B" the content shall disappear and other content shall appear on that place instead.

i tried to use the Frame control for that:
i defined 2 WPF Pages (one for content of Button A and one for content of Button B), and on pressing the button the frame.Content was set to the desired page.
But unfortunately as soon as i reset the content to something else i get the navigation bar.
is there a way how i can remove that navigation pane?  i only want the contents of the page visible and no navigation.


wpf listbox

$
0
0

Hello,
The listbox inside the wpf window is populated as in .xaml below:

<ListBox Name="lstNames"
                 ItemsSource="{Binding Path=DataCollection}"
                 SelectedValuePath="StudentID"
                 SelectedItem="{Binding Path=DetailData,Mode=TwoWay}"
                 DisplayMemberPath="FullName"
                 HorizontalAlignment="Left" Height="253" Margin="10,10,0,0" VerticalAlignment="Top" Width="236"
                 SelectionChanged="lstNames_SelectionChanged" Grid.ColumnSpan="7"></ListBox>

How do I change the above .xaml so that the listbox is populated for each student with FullName followed by an image of the student. Note for the first bversion, I have the .jpg of each students in the image folder.

I know I have to place item and data template but not sure where to put them with controls to hold FullName as well as image

?

Thank you

how do I change it so that


Multiple transitional element on same wpf doesn't work

$
0
0

Am working on C# wpf application where am using Transitionals framework for animations (https://transitionals.codeplex.com/)

I have 3 different transition elements on same wpf application. Each have unique name, also 2 has same effects whereas one has different effect, but on running the application all three gives same effect, changing randomly between those 2 effects (fade and Rotate).

Here is my XAML code :

<Grid Grid.Row="3"><transc:TransitionElement x:Name="livecheck" Height="30" VerticalAlignment="Bottom" Margin="180 10 250 15" Width="140"><transc:TransitionElement.TransitionSelector><trans:RandomTransitionSelector><transt:FadeTransition/></trans:RandomTransitionSelector></transc:TransitionElement.TransitionSelector></transc:TransitionElement><transc:TransitionElement x:Name="formatcheck" Height="30" VerticalAlignment="Bottom" Margin="360 10 20 15" Width="160"><transc:TransitionElement.TransitionSelector><trans:RandomTransitionSelector><transt:FadeTransition/></trans:RandomTransitionSelector></transc:TransitionElement.TransitionSelector></transc:TransitionElement></Grid><Grid Margin="410,5,12,15" Grid.Row="4"><transc:TransitionElement x:Name="TransitionBox" Height="66" VerticalAlignment="Bottom" Width="105"><transc:TransitionElement.TransitionSelector><trans:RandomTransitionSelector><transt:RotateTransition Angle="45" /></trans:RandomTransitionSelector></transc:TransitionElement.TransitionSelector></transc:TransitionElement></Grid>


How to parse efficiently a string to build a sub set of string

$
0
0

Dear all,

I have a WPF application for which I need to parse a long string with specific PREFIX caracters that identify a field value, then for each of this field value I will store the extracted string to a property.

The string to be parse is the following :

 string Code = "]d290FR00720032500323114142816131952240D370701022P05T1411140522";

The bold successive value in string above represent the prefix to be search in order to extract corresponding string.

For instance 290 prefix represent Manufacturer code which is FR007

The string between 2 different Bold caracters will represent a field as bellow :

Manufecturer Ref : FR007
ConditionCode : 03

UniqueCode : 0323114142816131952

ProductCode :D37070

Batch Number : 22/05/14

Manufacturing Date :140522

What is the best efficient way to parse each of those sequence caracters which identify each field to retrive ?

Thansk for advise

restart timer

$
0
0

Hi! i'm tring to reset the timer when tab change but it does not working.. how to do it? thanks!!

Timer.Start();

            RD1.Text =

"0";

            D1.IsEnabled =

false;

            D2.IsEnabled =

true;

            D2.Focus();

            Timer.Stop();

Integrate Cortana with WPF in Windows 10

$
0
0

Hi everybody,

I was wondering if there is a way to add Cortana support to WPF applications written in Windows 10. Ido not speak about Windows 10 Store apps, but about WPF.

Thanks a lot for your replies.

Jymmy097

Binding the object / objects

$
0
0
If I have a view which allows the user to add a new applicant, is it best to create a blank applicant object then bind to that, then construct another applicant object on save which will use the previous object and add anything additional?


Mouse hover effect

$
0
0

Hi All ,

I want to how to Apply and create Mouse Hover effect...... Looks like AVAST antivirus Mouse Hover Effect

Please find below attached Image.

Thanks

A.Aniruddhan


A.Acharya Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Working with caret in Text Formatter API

$
0
0

Hello!

I'm creating simple WPF text editor via Text Formatter API. I've already done some of the basic functionality and now I need to add a caret support. I also have a visual caret (just a line with blinking animation) that should be synchronized with rendered text. I found a bunch of methods in TextLine class, such as GetNextCaretCharacterHit , GetPreviousCaretCharacterHit , GetBackspaceCaretCharacterHit . But the documentation information about them is ...quite scarce.Could somebody who has some experience in that field explain how to deal with these methods, because I have almost no idea about that?

I tried to search the information in the internet, but as a result I found nothing.

I would be grateful for any help!


Get application path ?

$
0
0

 

hi all - probably a dumb question, but the Application object seems to not contain the path to the exe in WPF, how do I get that, in my code ?

 

Lync PresenceIndicator in WPF-app slows everything down

$
0
0

Hi there,

I am building a WPF-app wich includes a Lync (2013) PresenceIndicator and it works sort of fine.

I have build a DataTemplate in a ListBox and it includes a PresenceIndicator. 

But sometimes I show up to around 70 people in my ListBox and it slows down EVERYTHING in the app.

I would like to give the user the opportunity to toggle the PresenceIndicator on and off and have done so with the use of a DataTrigger. My DataTrigger sets Visibility to Visible/Collapsed and this works - but it has no effect on performance.

I have tried to set the Source in the PresenceIndicator to x:NULL - also no effect on performance.

Is there anyone who can give some advice?

Best regards,

Steffen


SteffenJ

How to route the buttons tap event to its parent listview?

$
0
0


<ListView Grid.Row="1"
                      ItemsSource="{x:Bind ViewModel.ColoredButtons}"
                      IsTapEnabled="True"
                      Tapped="{x:Bind ViewModel.Check}"><ListView.ItemTemplate><DataTemplate x:DataType="Model:ColoredButton"><Button Content="{x:Bind ColorName}"
                     Background="{x:Bind ButtonColor}"<!--This doesnt work-->Tapped="{x:Bind ViewModel.Check}/></DataTemplate></ListView.ItemTemplate></ListView>

I have a list view with binded itemSource and its data template contains a button

The problem is when I tap a button. theres no information to which button is tapped from the tapped event handler of listView

and if I use the click event handler, the click wont be raised. Last thing, I cant seem to handle the event inside the button of datatemplate



Binding value to Converter Parameter

$
0
0

Hi ,Whether we can give Converter parameter value through binding or else is there any alternative regarding this.

 <Rectangle VerticalAlignment="Stretch" x:Name="A" Width="{Binding AA, Converter={StaticResource AConvert}, ConverterParameter=300}"
                                            Fill="#FFD49831" />
            <Rectangle  VerticalAlignment="Stretch" x:Name="B" Width="{Binding BB, Converter={StaticResource AConvert}, ConverterParameter={Binding ElementName=A},Path=Width}}" 
                                            Fill="Green" />

Thanks in advance


Efforts may fail but don't fail to take effort -------------- sidd

How to create a proper tile icon for WPF app?

$
0
0

Hello all. How does one go about making an icon for a WPF application for when the user pins the application to the start menu (on Windows 8/8.1/10) it looks like a proper tile and not a small "traditional" desktop icon embedded in a tile? I'm also interested in creating an icon for multiple sizes of tiles. Any info is greatly appreciated. Thank you in advance.

-L

Viewing all 18858 articles
Browse latest View live


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