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

How to create attractive 2D and 3D animation by Blend 4.0 tool ?

$
0
0

Hi all,

          I want to  attractive 2D and 3D animation  use in my application . So please  send me best link for create animation in Microsoft Expression Blend Tool 4.0.

    Thanks 

Aniruddha Acharya


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.


ToolTip with multi-line

$
0
0

 

Hi,

How do I make a multi-line tooltip ?

I tried to set the ToolTip property of a control to:

 

ToolTip="AAA\r\nBBB"

 

but it does not work.

 

Yoav.

Can we use Microsoft Expression Blend 4.5 Tool in Window 7 O.S. ?

$
0
0

Hi All ,

         Can we use Microsoft Expression  Blend 4.5 Tool in Window 7 O.S. ? 

    Thanks

Aniruddha Acharya


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.

How to display Windows 8 keyboard close to a Text box field

$
0
0

Dear all,

We have build a WPF kiosk application running in Windows 8 Desktop ( not store based).

IN that application we have some text box field and when we touch the text box the On screen keyboard is not appearing on top of the app and near the selected touch text box.

Is there a trick to do that ?

regards

Specify main window by using Application.MainWindow property

$
0
0

I want to specify the main window in file xaml. How to use Application.MainWindow property to do this.

I should use what property in window element ?

<Application.MainWindow><Window ... /></Application.MainWindow>

How many difference between WPF 4.0 and WPF 4.5 ?

$
0
0

Hi All,

              How many major  difference between WPF 4.0 and WPF 4.5 .

   Thanks

  Ani  Acharya      


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.

Changing TreeViewItem colors using Style for TreeView

$
0
0

Hello,

I have a treeview which I'm styling as such (and it works fine):

     

    <Style x:Key="GenericTreeViewStyle" TargetType="{x:Type TreeView}">
        <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>

    </Style>

    ....

    <TreeView Name="myTreeView" Style="{StaticResource GenericTreeViewStyle}" >

                    <TreeView.Resources>

                        <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="Blue" Offset="0"/>
                            <GradientStop Color="DarkBlue" Offset="1"/>
                        </LinearGradientBrush>
                        <LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="DarkGreen" Offset="0"/>
                            <GradientStop Color="Green" Offset="1"/>
                        </LinearGradientBrush>
                        <!-- Text in the TreeViewItem for when it's selected and focused -->
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White" />
                        <!-- Text in the TreeViewItem for all other cases -->
                        <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Red" />
                    </TreeView.Resources>

                </TreeView>

I'd like to make this a generic style that all instances of treeviews can pick up.  So, I'd like to move everything from the TreeView.Resources chunk to GenericTreeViewStyle (or whatever other place necessary to achieve my goal).  All my attempts have failed so far so I must be missing something.  Appreciate your guidance please!

snaplines not showing in design view

$
0
0

Hi,

     I have recently migrated from winforms to wpf . I am having difficulty in aligning controls as i cant see the snaplines when i move a control relative to another controls edge.

Please help 

Regards

Sanjish


Updating xmlSource from a Listbox

$
0
0

Hi

I'm raw when it comes to using WPF and c# so forgive me if I'm asking a basic question.<o:p></o:p>

I have a Stackpanel with a Listbox and a set of Textblocks which are bound together. The Listbox gets its values from an xml file. The bindings work great. My problem is I want the result of changing the Listbox to be saved back to the source xml file and I'm unsure how to do this. I've hunted high and low and can't find anything to guide me. 

I've a button that I want to use to update the source file testxml.xml but I'm unable to code the click event to perform the update. 

How do I code the UpdateButton_Click so that the source gets updated from the Listbox? Any help much appreciated.

Key components of my xml coding are:

<StackPanel.Resources><XmlDataProviderx:Key="xmlFeed"Source="c:\users\brian\desktop\testxml.xml"XPath="Greens/item"/></StackPanel.Resources>

...

            <ListBoxName="entryListBox"Height="300"Width="200"ItemsSource="{Binding Source={StaticResource xmlFeed}, XPath=//Greens/item}"IsSynchronizedWithCurrentItem="True"Visibility="Visible"SelectionMode="Single"><ListBox.ItemTemplate><DataTemplate><TextBlockText="{Binding XPath=title}"/></DataTemplate></ListBox.ItemTemplate></ListBox>
<TextBlockGrid.Row="0"Grid.Column="0">Title</TextBlock><TextBoxGrid.Row="0"Grid.Column="1"Name="titleText"Text="{Binding XPath=title}"/><TextBlockGrid.Row="1"Grid.Column="0">URL</TextBlock><TextBoxGrid.Row="1"Grid.Column="1"Name="urlText"Text="{Binding XPath=guid}"/><TextBlockGrid.Row="2"Grid.Column="0">Date</TextBlock><TextBoxGrid.Row="2"Grid.Column="1"Name="dateText"Text="{Binding XPath=pubDate}"/><TextBlockGrid.Row="3"Grid.Column="0">Body</TextBlock><TextBoxGrid.Row="3"Grid.Column="1"Name="bodyText"TextWrapping="Wrap"Text="{Binding XPath=description}"/><ButtonGrid.Row="4"Grid.ColumnSpan="2"Grid.Column="0"Click="updateButton_Click">
            		Update</Button>


 

<o:p></o:p>

Master Detail relations in WPF XAML

$
0
0

I'm trying to make a Master/Detail relationship between a ComboBox and a DataGrid.

In my DataSet I have 2 tables and a Relation between the two.

I set the DataContext of my Window in XAML to a ViewModel class.

I set the ItemsSource of the ComboBox to a BindingListCollectionView    (ItemsSource="{Binding TheBLCV}").

I can get the DataGrid to correctly display the rows corresponding to the selection in the ComboBox if I set the DataGrid's ItemsSource in code behind with this:

 

Binding bnd;
bnd = new Binding("TheRelation");
bnd.Source = TheBLCV;
TheDataGrid.SetBinding(.....ItemsSourceProperty, bnd);

But, I want to do the binding of the DataGrid in XAML and not code behind. I just cant figure our the syntax. When I do it in the code behind, the Binding's source is the same BindingListCollectionView as the ComboBox and the Binding's Path is the name of the Relation. But I don't know how to do it in XAML. Somehow I have to tell the ItemsSource to use the same BLCV but the path should be the Relation

Michael

Get a particular cell value in the WPF datagrid row when a different cell is selected

$
0
0

Hi, using Visual C# 2010 Express, in WPF datagrid I have SelectionUnit="CellOrRowHeader"
The datagrid is populated by a datatable from a database query
Now,

1) when the user selects any cell in the datagrid I want to read certain cells on the same row as the selected cell
Let's say, if cell [row=5, col=2] is selected I want to now get values in cell [row=5, col=1]
How can I do this?

2) When I select any Cell, why is the grid SelectedIndex always '-1' ?
In traditional winforms datagridview, selecting any cell would make the corresponding row the Current Row
How to make the row of a selected cell the Current Row in WPF?
I don't want to change SelectionUnit="CellOrRowHeader" because I want to let users select specific cell so they can copy the contents of that cell only
Also, is there an easy way to show the current row indicator in WPF datagrid (like the triangle in row header in winforms datagridview)?


Thanks,
-sri


sri

Determine WPF DataGrid Checkbox Status

$
0
0

I have a DataGrid with two columns (Name and Status).  The Status column is an unbound column with checkboxes.  I'm am trying to obtain the Names (In a String) in the first column with the corresponding Checkboxes that are checked in the second column.

Any suggestions?  Thanks

How to get started with WPF

$
0
0
How to get started with WPF?
Can i make use of WPF in asp.net?

Portable Class Library WCF Async/Completed Exception Handling

$
0
0

Hello,

I'm building a Portable Class Library that wraps a WCF Service Reference and targets .NET 4.5, Windows Store, Windows Phone.

I have hit somewhat of a roadblock, the generated proxy classes are using the async pattern <MethodName>Async(...) methods and <MethodName>Completed(...) events.  While it is claimed that the exception will be forwarded to the Completed event should an error happen this is simply not the case.  During debugging or running without the debugger the exception is classed as unhandled and pops out of the generated EndXxx( ) method thus I cannot catch the exceptions and forward them to the client application (to display an appropriate message and continue execution).

The Completed event is not triggered until after the exception shows up in the debugger as unhandled.  What can I do to catch the exceptions in my Portable Class Library so that I might handle them properly?  Is there something I'm missing?

Thank you!

Here's a cut down version of the code that makes a call to the WCF service client that I expect to throw an exception (for testing purposes).

public static Task<T> TryOperationAsync<TClient, T>(TClient client, Func<TClient, T> operation)
	where TClient : class, ICommunicationObject
{
	return Task.Factory.StartNew(( ) =>
	{
		try
		{
			T result = operation.Invoke(client);
			client.Close( );
			return result;
		}
		catch (Exception ex)
		{
			client.Abort( );
			throw ex;
		}

		return default(T);
	});
}

public async Task<IEnumerable<DataObject>> LoadDataAsync( )
{
	return await SharedServiceHelper.TryOperationAsync(serviceClient, client =>
	{
		ManualResetEvent waitHandle = new ManualResetEvent(false);
		Exception error = null;
		client.GetDataCompleted += (sender, e) =>
			{
				error = e.Error;
				try { cache = e.Result; } catch { }
				((ManualResetEvent)e.UserState).Set( );
			};

		// block this operation until the completed event is fired..
		// this effectively the same as calling await SomeOperationAsync(...)
		waitHandle.Reset( );
		client.GetDataAsync(waitHandle);
		waitHandle.WaitOne( );

		if (error != null) throw error;
		return clientCache;
	});
}




Question about sorting Detail table

$
0
0

Someone posted almost the exact same question here.  I attempted to use that answer in my situation but am not sure how to form the syntax.  I'm using WPF and EF.

I, too, have a master/detail situation that uses a combo box that fills a datagrid.  The combo is sorted by patient name.  I'd like the grid to sort by appointment date.

The EF wizard created the following code (I added the sort description).

        Dim TblPatientDemographicViewSource As System.Windows.Data.CollectionViewSource =
            CType(Me.FindResource("TblPatientDemographicViewSource"), System.Windows.Data.CollectionViewSource)

        'sort view by patient name.  
        TblPatientDemographicViewSource.SortDescriptions.Add(New SortDescription("PatientName", ListSortDirection.Ascending))

        'Load data by setting the CollectionViewSource.Source property:
        'TblPatientDemographicViewSource.Source = [generic data source]
        _context.tblPatientDemographics.Load()
        TblPatientDemographicViewSource.Source = _context.tblPatientDemographics.Local

The suggested answer (converted to vb.net from c#):

        DirectCast(TblDentistAppointmentsDataGrid.Items, ItemCollection).SortDescriptions.Add(New System.ComponentModel.SortDescription("DentistAppointmentDate", System.ComponentModel.ListSortDirection.Ascending))

I'm not sure where to place this suggested code in my code block.  More importantly, I'm not sure the syntax is correct.  Looking at the xaml, I noticed the resource name:

<DataGrid x:Name="TblDentistAppointmentsDataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True" 
                  ItemsSource="{Binding Source={StaticResource TblPatientDemographictblDentistAppointmentsViewSource}}" 
I thought maybe that resource is what I should apply the sort description to but that is not an option when forming the syntax. 

Thanks.



Textblock not showing when opening XAML image

$
0
0

Hi all,

I ran across a problem where I'm drawing lines and text blocks on a canvas. When I save the canvas using the XAMLWriter, the lines show up but not the text blocks. I'm opening the XAML file in Inkscape. Some example code below shows what I'm trying to illustrate.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Markup;


using System.IO.Packaging;


namespace ExampleWPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            draw();
            save(canvas1);
        }

        public void draw()
        {
             canvas1.Children.Clear();
             this.UpdateLayout();

             
           
                Line myLine = new Line();
                myLine.Stroke = System.Windows.Media.Brushes.Black;
                myLine.X1 = -125.000;
                 myLine.X2 = -135.000;
                 myLine.Y1 = 216.5063509;
                 myLine.Y2 = 233.82685;
                myLine.StrokeThickness = 1;
           
                    TextBlock textblock = new TextBlock();
                    FontFamily family = new FontFamily("Arial");
                    textblock.Text = "0";
                    textblock.FontSize = 8;
                    textblock.FontFamily = family ;
                    Canvas.SetLeft(textblock, -145.00000000000003);
                    Canvas.SetTop(textblock, 243.82685);
                    canvas1.Children.Add(myLine);
                    canvas1.Children.Add(textblock);

        }

        public void save(Canvas canvas1)
        {
            string myXAML = XamlWriter.Save(canvas1);
            FileStream fs = File.Create("testfile2.xaml");
            StreamWriter sw = new StreamWriter(fs);
            sw.Write(myXAML);
            sw.Close();
            fs.Close();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            draw();
            save(canvas1);
           // this.UpdateLayout();
        }


    }
}

Thinking animation to WPF when working a-sync

$
0
0

HI


I have list box that are getting data from service ,sometimes the service are taking about 15 sec to load the data

to the list box.

1. How can I provide some thinking animation while the list is loading (I want the standard windows thinking animation)

2. how can I change the list to work A-sync  i.e. when the list is loading the user can use the page since currently

the page is waiting to the response...


<ListBox
                  Visibility="{Binding IsLoaded,
                  Converter= {StaticResource BooleanToVisibilityConverter}}"
                  ItemsSource="{Binding ServiceData}"
                  FontSize ="15"
             HorizontalAlignment="Left" Margin="115,0"> 

This is the list box which is bound to the view model.

Thank you!

Fix the column of gridviewColum so that it does not resize

$
0
0

I have a wpf List View control. For the grid column i have specified the width.

However, the column can be resized by the user. I want dont want to give this feature.

How do i do this?

WPF code is below

   <ListView x:Name="lstBacnetDeviceList" VerticalAlignment="Top" Margin="0,0,0,2" FontFamily="Microsoft Sans Serif"
                  local:ListViewSorter.CustomListViewSorter="ReflashTool.Components.ListViewSorter.DevicePropertiesComparer"
                  >
            <ListView.Resources>
                <ordinal:OrdinalConverter x:Key="OrdinalConverter" />
                <DataTemplate x:Key="OrdinalColumnDataTemplate">
                    <Border BorderBrush="#FF000000" BorderThickness="0.25,0.25,0.25,0.25" Margin="-6,-8,-7,-10" Padding="0,2,0,0" HorizontalAlignment="Center" Width="35" Background="LightGray">
                        <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListViewItem},
            Converter={StaticResource ResourceKey=OrdinalConverter}}"  HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                </DataTemplate>
            </ListView.Resources>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="35" CellTemplate="{StaticResource ResourceKey=OrdinalColumnDataTemplate}" />
                    <GridViewColumn Header="Select" Width="50" local:ListViewSorter.PropertyName="DeviceSelected">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Border BorderBrush="#FF000000" BorderThickness="0.25,0.25,0.25,0.25" Margin="-5,-8,-7,-10" Padding="0,0,0,0" Width="50">
                                    <CheckBox Name="chkDeviceSelect" IsChecked="{Binding Path=DeviceSelected,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                </Border>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Device ID" Width="100" local:ListViewSorter.PropertyName="DeviceAddress">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Border BorderBrush="#FF000000" BorderThickness="0.25,0.25,0.25,0.25" Margin="-5,-8,-7,-10" Padding="3,2,0,0">
                                    <TextBlock FontFamily="Microsoft Sans Serif" Text="{Binding Path=DeviceAddress}" Width="98"  HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                </Border>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn> </GridView>
            </ListView.View>
        </ListView>

validation for 2 telerik:radDatePicker (start date and end date).

$
0
0

Hi.

I have 2 telerik:radDatePicker control(start date and end date).

Where User should be able to select start date and end date.

End date should be lass then and not equal to end date.

I want  to give  validation when user leave the end date(telerik:radDatePicker control) at that time.


yogesh_vns2

Data binding

$
0
0

Is it possible to bind the IsEnabled Button property to the load/unload of a FlowDocument?

VM

Viewing all 18858 articles
Browse latest View live


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