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

How to hide items of a comboBox according to a value of a property without using converter, only in AXML?

$
0
0

I am use this example to simply my case.

I have two comboBox, one is for persons and other for orders. Order has a IDPerson property, so I can know who person is the owner of the order. The comboBox has all the orders of all the clients, so I want that when I select a person in the first comboBox, in the second comboBox show only the orders of this person.

So the second comboBox has to check if the Order.IDPerson is the same than Person.IDPerson of the first comboBox.

I am trying something like that:

<ComboBox.ItemContainerStyle><Style TargetType="ComboBoxItem"><Setter Property="Visibility" Value="Hidden"/><Style.Triggers><DataTrigger Binding="{Binding ElementName=cmbPersons, Path=SelectedItem.IDPerson}" Value="{Binding ElementName=cmbOrders, Path=SelectedItem.IDPerson}"><Setter Property="Visibility" Value="Visible"/></DataTrigger></Style.Triggers></Style></ComboBox.ItemContainerStyle>

But i get an error because value can't use a binding.

Is it possible to do that without a converter?

Thanks so much.


How to convert xps documents to other formats, for example bmp ?

$
0
0
Hi, I have one question to ask.
How to convert xps documents to other formats, for example bmp format?
Thanks!

bindingsource ui and entity framework 6

$
0
0
Hello.
I started to study the WPF,
1) in the data part, I saw several examples and use objects to store other data to list observablelist to enumerable etc ....
It 'a difference by architectural reasons or just from the date of application and change of entity framework? I use Entity Framework 6.
what are the collections that it is better to use, in short if the speech is complex.
2) In the ui part I use the DevExpress objects but what I do not understand is that until now with win forms I used the BindingSource and relationships (the DataRelation) I do not see more in no instance even if on a book by entity framework She teaches how to use it.
Again , this choice is in the architectural or not?
Because with data relations was simple create multi detail grid , but in entity framework there are the associations....can work as the relations in entity framwork?
bindingsource or not?

thank you.

Exception from HRESULT: 0xC1311010

$
0
0

I am having a TextBox with spell checker enabled and custom dictionary added. When i give relative path for the custom dictionary, the "Exception from HRESULT: 0xC1311010" is throwing in designer. If i give absolute path, then everything works fine for me.

Any help would be greatly appreciated.

Regards.


Aaru


Notifications to WPF app using PHP

$
0
0
I am developing an WPF app (Exe for Windows 7 and above) and whenever any event occurs on CMS I need to notify WPF app through notifications. All examples I found are using WCF services but beckend for my CMS is in PHP. So Is it possible to send notifications to WPF app using PHP? How?

In a comboBox with a compositeCollection, if I select first element the comboBox is turn to red

$
0
0

I am trying to use  a CompositeCollection to add a empty item in the comboBox. I am trying this code.

<ComboBox x:Name="cmbOrders" HorizontalAlignment="Left" Margin="5,16,0,0" VerticalAlignment="Top" Width="120"
                  IsEditable="True"
                  IsTextSearchEnabled="False"
                  Text="{Binding OrdersText, UpdateSourceTrigger=PropertyChanged}"
                  DisplayMemberPath="Order"><ComboBox.Resources><CollectionViewSource x:Key="comboBoxSource" Source="{Binding ElementName=cmbPersons, Path=SelectedItem.Orders}" /></ComboBox.Resources><ComboBox.ItemsSource><CompositeCollection><ComboBoxItem Content="Empty" ></ComboBoxItem><CollectionContainer Collection="{Binding Source={StaticResource comboBoxSource}}" /></CompositeCollection></ComboBox.ItemsSource></ComboBox>

I display the elements correctly, when I select an intem in the Persons comboBox, in the Orders combobox I display in the first position the empty element and later the orders of the person selected in the first comboBox.

The problem is that when I select the empty item the comboBox it is turn to red, like when I set an incorrect value in a control.

How could I avoid this behavior?

Thanks.

EDIT: I have notice that when I select this empty element the selectedItem is not fire, but the SelectedIndex do it. I guess that the origen of the problem is the same, but I would like to use selectedItem always.


Page can have only Window or Frame as parent

$
0
0

Hello

i displayed without problem a page in a frame (WPF Application).
Now on this page, I put a Docking Manager Control (Avalon Dock). I have to dynamically add pages to Docking manager  as Tab. so I use the following code.

var documentPane = DocManager.Layout.Descendents().OfType<LayoutDocumentPane>().FirstOrDefault();
             LayoutDocument layoutDocument = new LayoutDocument { Title = "Home Page", ContentId = "HomePage" };

             for (var ix = 0; ix < documentPane.ChildrenCount; ix++)
                 if (documentPane.Children[ix].ContentId == strid)
                 {

                     documentPane.Children[ix].IsSelected = true;
                     return;
                 }
              HomePage hp = new HomePage();
             layoutDocument.IsSelected = true;
             layoutDocument.Content = hp;
             documentPane.Children.Add(layoutDocument);

result: I get the following error message:

Page can have only Window or Frame as parent

How can I solve this problem or how do I add the page to avoid this problem?

Thanks


displaying data from the database in wpf project using wcf services?

$
0
0
can anybody guide me how to display data from mysql database using the wcf service in wpf project using c#?i have gone through many example on the internet but not a single one was able to display data?

System.IO.Path.GetFullPath() returns different values on compile time and on design time

$
0
0
System.IO.Path.GetFullPath() returns different values on compile time and on design time. I have checked this using Log file. The values look different.

Aaru

How to convert byte array image type in sql server to its respective document?

$
0
0

Hi,

I'm able to upload documents in my WPF C# application in the form of byte array image type in sql server. I've to show these documents in a listbox and allow the user to be able to download the document. The type could be office documents (word, ppt, excel) or pdf.

Thanks in advance!

Pulkit Gulati

How to know Touch was hold or in moving position in WPF

$
0
0

Hello,

How to know Touch was hold or in moving position on the PreviewTouchUp Event or in another way. If possible please guide me how to fix this problem.

Thanks in advance.

How to cancel editing in DataGridTemplateColumn when Validation detects an error

$
0
0

Hello,

I have a DataGridTextColumn with a Validation attached to the property binding.  Even when the validation fails, the user can cancel editing by pressing the Escape key.

I have a DataGridTemplateColumn with a DatePicker in the CellEditingTemplate and would like to get the same functionality -- allow the user to cancel editing, regardless of what the validation detects.

There is Validation attached to the data binding, and a LostFocus handler:

var dateValidationRule = new DateValidationRule(); dateValidationRule.PropertyName = bindingPath; dateValidationRule.ValidatesOnTargetUpdated = true; b.ValidationRules.Add(dateValidationRule);

datePickerFactory.AddHandler(LostFocusEvent, new RoutedEventHandler(DatePickerLostFocusHandler));      

I have a KeyUp handler configured in the Style for DataGridCell; in the handler, I'd like to end editing when the Escape key is pressed:

private void DataGridCell_KeyUpHandler(object sender, KeyEventArgs e)
{
    DataGridCell cell = sender as DataGridCell;
    if (cell != null && e.Key == Key.Escape)
    {
        cell.IsEditing = false;
    }
}

Unfortunately, this doesn't work, and I suspect it is because there is still a validation error detected by the LostFocus handler.
I am also trying this:

if (Validation.GetHasError(datePicker))
{
    var b = datePicker.GetBindingExpression(DatePicker.SelectedDateProperty);
    if (b != null)
    {
        Validation.ClearInvalid(b);
    }
}

Unfortunately, b is always null -- how can I get the correct binding to clear the Validation errors? I think if I can get this last snippet working, I'll be able to cancel editing.

Thanks --


List view TabNavigation Problem

$
0
0

I have ListView like as:

<ListView Grid.Row="1" Grid.ColumnSpan="2"

ItemsSource="{Binding DailyVCRGenModel.HistoryListCollection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"

Margin="0,0,0,0" x:Name="vcrListView" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="420" Width="1330"

HorizontalAlignment="Center" KeyboardNavigation.TabNavigation="Continue">

I want to fix tabbing sequence between line items, limit it to only tab through 'buttons' only .

Or in another words=>

I want to tabbing within two columns of button only  instead of first(description). How to fix this problem?



WPF MVVM swapping an image in the view from the viewmodel

$
0
0
I have an application with a simple form.  I need to be able to swap an image in the view based ion a method I have in the viewmodel. 

How to refresh user control on the button click in WPF

$
0
0

I am showing user control on the popup. Like as:

xmlns:TimelogCustomControl="clr-namespace:TechTouch.CustomControl"

And showing in the grid control like as:

<Grid Grid.Row="1" VerticalAlignment="Top" Grid.ColumnSpan="2"><TimelogCustomControl:OnDutyPopUp  Value="{Binding TimeLogModel.HeaderDutyText,Mode=TwoWay}"   VerticalAlignment="Top"></TimelogCustomControl:OnDutyPopUp></Grid>

And now i want to refresh data of this user control on the button click for that We will show updated functionality on this page. How to fix this. problem.
If possible please guide me? I am seeking this problem from few days.

thanks in advance.


Any free PDF Viewer for WPF?

$
0
0
Any free PDF Viewer for WPF?

Designer

WPF XAML Exception - "Add value to collection of type 'System.Windows.Interactivity.TriggerActionCollection' threw an exception

$
0
0

My project is in WPF using MVVM. I am using Interaction,Triggers -> i:EventTrigger to notify about any validation errors in control.

This application works all the time and already in production. But last week, we found out a client has a problem loading a view. Application crashes while loading the view. And it happens all the time. We can not reproduce it in out environment.


The following details were captured from client machine.

Errors in Event Viewer => Message: HandlingInstanceID: 01453795-4b3a-4765-b651-44c11594b402 An exception of type 'System.Windows.Markup.XamlParseException' occurred and was caught.

03/31/2016 15:16:09 Type : System.Windows.Markup.XamlParseException, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Message : Add value to collection of type 'System.Windows.Interactivity.TriggerActionCollection' threw an exception. Source : PresentationFramework Help link : LineNumber : 0 Line"margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;white-space:pre-wrap;background-color:#eff0f1;">1 affectedChildren, UncommonField1 templatedNonFeChildrenField) at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List1 affectedChildren) at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate) .................... (Very long stack trace)

**InnerException**---------------Type:System.ArgumentException, mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089Message:Cannot add instance of type 'EventToCommand' to a collection of type 'TriggerActionCollection'.Only items of type 'T' are allowed.Source:PresentationCoreHelp link :ParamName:Data:System.Collections.ListDictionaryInternalTargetSite: T Cast(System.Object)HResult:-2147024809StackTrace:    at System.Windows.FreezableCollection`1.Cast(Object value)
   at System.Windows.FreezableCollection`1.System.Collections.IList.Add(Object value)
   at System.Xaml.Schema.XamlTypeInvoker.AddToCollection(Object instance,Object item)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.Add(Object collection,XamlType collectionType,Object value,XamlType valueXamlType)

Another Exception

04/21/2016 11:52:09 Type : EAF.Infrastructure.Exceptions.DevicePartDiscoveryException, EAF.Infrastructure, Version=1.0.1.538, Culture=neutral, PublicKeyToken=null Message : A module cannot be imported. The following issues were found while trying to import a module: Could not load file or assembly 'System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Inner Exception --------------- Type : System.Reflection.ReflectionTypeLoadException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Source : mscorlib Help link : Types : System.RuntimeType[] LoaderExceptions : System.Exception[] Data : System.Collections.ListDictionaryInternal TargetSite : System.RuntimeType[] GetTypes(System.Reflection.RuntimeModule) HResult : -2146232830 Stack Trace : at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeModule.GetTypes() ......................

I already checked the version of System.Windows.Interactivity and its correct version.(I am using .Net framework 4.5) 

Finding the Grid row index of a button in that row from the button click event.

$
0
0

I have a grid in a WPF app. The grid can have rows added and deleted dynamically when the user presses one button to add a row and another button to delete a row.   The buttons are in the rows themselves. If the user presses the delete button, the row in which the button resides is to be deleted.  My problem is that I don't know how to find the index of that row from the button's click event.  Here is the XAML for the grid:

<Grid
                    Canvas.Top="653" Canvas.Left="0"
                    Width="734.4" Height="auto"
                    Name="grdVictims"  IsManipulationEnabled="True">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="78" Name="RowDefVictimGrid"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="{Binding Width}"/>
                    </Grid.ColumnDefinitions>
                    <Border
                        Grid.Column="0" Grid.Row="0"
                        BorderBrush="Black" BorderThickness="1,0,1,1">
                        <Canvas
                            Width="734.4">
                            <!-- Binding the size again.  Canvas to match border size-->
                            <TextBlock Height="24" Text="  VICTIM NAME"></TextBlock>
                            <TextBlock Height="24" Text="  RELATIONSHIP" Canvas.Left="367.2"></TextBlock>
                            <TextBox
                                Name="txtVTSRVictimName"  
                                Height="24" Width="366"
                                Canvas.Top="24" Canvas.Left="0"
                                BorderBrush="Black" BorderThickness="0,0,1,1"
                                GotFocus="RedUnderlineOn" LostFocus="RedUnderlineOff"/>
                            <TextBox
                                Name="txtVTSRRelationship"
                                Height="24" Width="367"
                                Canvas.Top="24" Canvas.Left="366"
                                BorderBrush="Black" BorderThickness="0,0,1,1"
                                GotFocus="RedUnderlineOn" LostFocus="RedUnderlineOff"/>
                            <Button
                                Name="btnAddVictim"
                                Canvas.Top="50" Canvas.Left="162"
                                Width="184" Height="24"
                                GotFocus="RedUnderlineOnBtn" LostFocus="RedUnderlineOffBtn" Click="AddVictim">Add Victim</Button>
                            <Button
                                Name="btnDeleteVictim"
                                Canvas.Top="50" Canvas.Left="383"
                                Width="184" Height="24"
                                GotFocus="RedUnderlineOnBtn" LostFocus="RedUnderlineOffBtn"  Click="DeleteVictim" UseLayoutRounding="True">Delete Victim</Button>
                        </Canvas>
                    </Border>
                </Grid>

The Grid starts as one row and one column.  The one object in the row is a border.  Inside the border is a canvas.  On the canvas two textblocks, two textboxes, and two buttons (Add and Delete).  Each button then, is in a canvas, within a border, within a grid.  How do I get the index to the row of the Grid from within a button's click event?

TextBox Lost focus while user type

$
0
0

Hello Friends

I am working on one type of calculator project. In that I am using Mahapps Metro control. Its working fine but some time when user type on textbox or select on combobox  project lost  focus on particular control. I couldn't able to find the reason. I just want to know Why control loosing there focus ? How I can overcome this problem.  Why this problem occurring? etc.

I didnt implemented selection change event on that textbox, just simple text binding which holds string property, and for combox I ave bind collection property and selectedItem property, Combobox implements selection change event. 

My both controls (textbox and Combobox) loose there focus some time. 

 

[WPF] How to create Binding in resources?

$
0
0

Goal: To create Binding in resources and use it in view model.

Problem: It gives lots of exceptions.

XAML:

<Window.Resources><Binding x:Key="binding" ElementName=rectangle Path=Width></Binding></Window.Resources><Grid><Rectangle x:Name="rectangle" Width="100" Height="100" Fill="Red"></Rectangle><Ellipse Width="{StaticResource binding}" Height="100" Fill="Blue"></Ellipse></Grid>
Viewing all 18858 articles
Browse latest View live


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