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

Wpf hotel booking system, using Wcf service vs Web Api?

$
0
0

Hi

I could use some advice in order to choose the right service to use. I'm working on a Wpf application, which is basically a small hotel booking system. The booking system should be installed on a computer, where the users (receptionists) can use it to perform a booking of a room.

The Wpf application should be using a MVVM pattern which should be the frontend. I want to have a service or something which can run on a server, so my Wpf application can connect to it to get a list of available rooms. 

I'm a bit confused what to use if we look at the "Wcf service" or a "Web Api". Could you maybe advice what is the best solution for what I need here?

The Wcf service or Web Api should be in its own project, and run on its own server. It should contain the logic and the entity framework with test data to use in the beginning. 

I have no experience with Wcf services, and when I look at google I can handly find any updated tutorials to use. Is Web Api much for populate or?

Hope to hear from you :)


Wavy underline of FormattedText

$
0
0

I want to draw a wavy underline allows FormattedText. I was set formattedtext.Set TextDecorations but when resizing fonts wavylines wrong.

i write:

var geometry =newStreamGeometry(); using (var context = geometry.Open()){ context.BeginFigure(newPoint(0.0,1),false,false); context.PolyLineTo(new[]{newPoint(1.5,0),newPoint(3,3),newPoint(4.5,1.5),newPoint(6,0),newPoint(7.5,3),newPoint(9,1.5)},true,true);}var brushPattern =newGeometryDrawing{Pen=newSystem.Windows.Media.Pen(System.Windows.Media.Brushes.Black,1),Geometry= geometry};var brush =newDrawingBrush(brushPattern){TileMode=TileMode.Tile,Viewport=newRect(0,0,9,4),ViewportUnits=BrushMappingMode.Absolute,Viewbox=newRect(0,0,9,4),ViewboxUnits=BrushMappingMode.Absolute,Stretch=Stretch.Fill};System.Windows.TextDecoration squiggly =newSystem.Windows.TextDecoration(); squiggly.Pen=newSystem.Windows.Media.Pen(brush,1.2);

Can you help me?

WPF: what wpf controls we should use?

$
0
0

Our WPF application needs a page which includes two controls which represents wells in a plate. Each well includes three properties: well name, part number, and well expire date.

One control is the plate control which includes 3x3 wells.

First row:        A1, A2, A3,

Second row:   B1, B2, B3

Third row:      C1, C2, C3.

Another control is the list control which includes 9 rows and 3 columns.

9 rows are A1, B1, C1, A2, B2, C2, A3, B3, C3 and columns represent well properties

When clicking one well in the plate control, it should highlight three wells in that selected row.

   For an example, if we highlight A2 well, application should automatically highlight A1, A2 and A3 wells.

Selections in both the Plate control and the List control should be synch.

If A1, A2 and A3 highlight in the plate control, A1, A2 and A3 rows should be highlight in the List control as well. Vise verse.

Does anyone has any suggestion how we should implement those two controls? Thx!


JaneC

datagrid

$
0
0
public partial class MainWindow : Window
    {
        DataTable dtSquad = new DataTable();

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < 5; i++)
            {
                dtSquad.Columns.Add(new DataColumn(i.ToString() + "column"));
            }

            DataRow drSquad;

            for (int i = 0; i <= 5; i++)
            {
                drSquad = dtSquad.NewRow();
                dtSquad.Rows.Add(drSquad);

                drSquad[0] = i.ToString() + "row";
            }

            dgdSquadResultBoard.ItemsSource = dtSquad.DefaultView;
        }
    }


<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="487" OpacityMask="#FFF08A8A" Foreground="#FFF08A8A" BorderBrush="#FFF08A8A" Background="{x:Null}" Loaded="Window_Loaded"><DataGrid x:Name="dgdSquadResultBoard" Margin="3,2,2,0" VerticalAlignment="Top" Height="312" ColumnWidth="100" RowHeight="50"/></Window>

I want to make the datagrid text(header, column, cell) alignment  center.

Answers, please.

How to Programatically Determine the Actual (fallback) CultureInfo?

$
0
0

If I build an application with XAML resources for "en" (base/default/fallback) and"en-US" cultures and execute the following code:

System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-GB", false);

the "en" fallback seems to be used but

System.Threading.Thread.CurrentThread.CurrentUICulture.ToString()

reports "en-GB"

How can I programmatically determine the actual, "fallen-back" culture (in the example,"en")?

DeltaManipulation event

$
0
0
Hello I, m using the ManipulationEvents for Multitouch in my ChartCursormodifier:

((SciChartSurface)ParentSurface).IsManipulationEnabled = true;

        ((SciChartSurface)ParentSurface).ManipulationDelta += BaseCursorModifier_ManipulationDelta;

        ((SciChartSurface)ParentSurface).ManipulationStarted += BaseCursorModifier_ManipulationStarted;

        ((SciChartSurface)ParentSurface).ManipulationCompleted += BaseCursorModifier_ManipulationCompleted;

        ((SciChartSurface)ParentSurface).ManipulationInertiaStarting += BaseCursorModifier_ManipulationInertiaStarting;




private void BaseCursorModifier_ManipulationStarted(object sender, ManipulationStartedEventArgs e)

    {

      Manipulation.SetManipulationMode((UIElement)sender, ManipulationModes.All);

      e.Handled = false;

    }

  



This works, but X and Y Coordinates are always  equal in ManipulationDeltaEventArgs.Expansion?

SVG implementation with WPF and browser control

$
0
0

Please suggest if with browser control with wpf can achieve below functionality:

Svg rendering 
Interactive svg where user can zoom in/out
Interactive svg where vehicle can moving on svg map.

Please suggest performance factor and any other control can be used to achieve above. 

Regards,
Amit

Drag and drop button

$
0
0
I need to drag a button in my application. while dragging the button i am generating a popup window. when the button is dropped over another control i need an event to hide my popup. Any solution for this..............Thanks in Advance

mohammed azarudeen




How to select only a line shape instead of selecting a big square

$
0
0

I'm working on a WPF project that has a ListBox bound to a collection. This ListBox shows the elements in a canvas since these elements are ellipses and lines.

I am developing an application where I can draw entities (ellipses) and connectors (lines). That's already working.

I also want to be able to select either a ellipse or a line which I can already do it, since this capability is provided by the ListBox. However, when I select a line, the selected line looks like an ugly big blue square!

Is there a way to select only the pure line?

Here is how my current ListBox implementation looks like:

<ListBox ItemsSource="{Binding Elements}" ><ItemsControl.ItemContainerStyle><Style><Setter Property="Canvas.Left" Value="{Binding CanvasLeft}" /><Setter Property="Canvas.Top" Value="{Binding CanvasTop}" /><Setter Property="Panel.ZIndex" Value="{Binding ZIndex, Mode=TwoWay}" /></Style></ItemsControl.ItemContainerStyle><ItemsControl.Resources><DataTemplate DataType="{x:Type vm:EntityViewModel}" ><Viewbox><Grid><Ellipse myb:DraggableBehavior.IsDraggingEnabled="True"
                            Stroke="Black"
                            Width="{Binding ShapeWidth, Mode=TwoWay}"
                            Height="{Binding ShapeHeight, Mode=TwoWay}"
                            Canvas.Left="{Binding X1, Mode=TwoWay}"
                            Canvas.Top="{Binding Y1, Mode=TwoWay}"
                            Fill="{Binding Background}"
                            Panel.ZIndex="{Binding ZIndex, Mode=TwoWay}" ></Ellipse><TextBlock Text="{Binding StatePropertiesViewModel.Name}"
                           HorizontalAlignment="Center"
                           TextAlignment="Center"
                           VerticalAlignment="Center" /></Grid></Viewbox></DataTemplate><DataTemplate DataType="{x:Type vm:LineViewModel}" ><Line X1="{Binding X1, Mode=TwoWay}"
                  Y1="{Binding Y1, Mode=TwoWay}"
                  X2="{Binding X2, Mode=TwoWay}"
                  Y2="{Binding Y2, Mode=TwoWay}"
                  Stroke="{Binding Color, Mode=TwoWay}"
                  StrokeThickness="{Binding Thickness, Mode=TwoWay}"
                  Panel.ZIndex="{Binding ZIndex, Mode=TwoWay}"
                  /></DataTemplate></ItemsControl.Resources><ItemsControl.ItemsPanel><ItemsPanelTemplate><Canvas /></ItemsPanelTemplate></ItemsControl.ItemsPanel></ListBox>

I just added the following code to the ListBox.ItemContainerStyle:

<Style x:Key="myLBStyle" TargetType="{x:Type ListBoxItem}"><Style.Resources><SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                             Color="Transparent"/></Style.Resources></Style>
it seemed that the blue square selection area is not visible now, it looks better. However, it is still there because, for example, if I have a Line shape over an Ellipse, I cannot select the ellipse since the invisible selected Line area is still there. i.e. what I get selected when clicking on it is the line, not the ellipse. So, is there a way to reduce the selection area just to the area of the shape itself?


Selection on tab Items not working WPF

$
0
0
I want load some data in two listviews , each of listview is in a separate TabItem. My problem is that I can load data in listviews but I can not select items from listliews.

If I select tab2 and after that again tab1 InterventiiList will remain always empty but I can select items from tab1.

What is wrong at my code?

My code is looking something like this:

private void populateLoadedTab(object sender, SelectionChangedEventArgs e)
    {
         if (tab1.IsSelected)
            {

                SesizariList.ItemsSource = sesizari;
                SesizariList.Items.Refresh();

            }
            else if (tab2.IsSelected)
            {
                    InterventiiList.ItemsSource = interventii;
                    InterventiiList.Items.Refresh();
            }


        }


<TabControl Name="TabCtrlSI" SelectionChanged="populateLoadedTab"><TabItem x:Name="tab1"></TabItem><TabItem x:Name="tab2"></TabItem></TabControl><ListView Name="SesizariList"/><ListView Name="InterventiiList"/>


Listview / Stackpanel is adding extra space, how do I get rid of it?

$
0
0

I would like the two stackpanels below to appear similar but the bottom appears to be adding extra spaces and is not bottom justifying things...

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Grid.Row="1" >
            <Rectangle Height="100" Width="5" Fill="Red" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="2"/>
            <Rectangle Height="90" Width="5" Fill="Red" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="2"/>
            <Rectangle Height="80" Width="5" Fill="Red" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="2"/>
            <Rectangle Height="70" Width="5" Fill="Red" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="2"/>
            <Rectangle Height="60" Width="5" Fill="Red" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="2"/>
            <Rectangle Height="50" Width="5" Fill="Red" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="2"/>
            <Rectangle Height="40" Width="5" Fill="Red" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="2"/>
            <Rectangle Height="30" Width="5" Fill="Red" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="2"/>
        </StackPanel>
       
       
        <ListView Grid.Row="2" ItemsSource="{x:Bind ViewModel.Data}" Padding="0" MaxWidth="800"  MinWidth="800" Margin="10" HorizontalAlignment="Left">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="Width" Value="20" />
                    <Setter Property="Padding" Value="0,0,0,0" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="0" Padding="0" Background="Yellow" BorderThickness="2" BorderBrush="Green" >
                        <StackPanel.Resources>
                            <Style TargetType="Rectangle">
                                <Setter Property="VerticalAlignment" Value="Bottom"/>
                                <Setter Property="HorizontalAlignment" Value="Left"/>
                                <Setter Property="Width" Value="20" />
                            </Style>
                        </StackPanel.Resources>
                    </StackPanel>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
           
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="local:QueryData">
                    <Rectangle Height="{x:Bind QueryCount}" Width="10"  Fill="Blue" StrokeThickness="2" Stroke="Black" Margin="0" />
                </DataTemplate>       
            </ListView.ItemTemplate>
        </ListView>

    </Grid>


nagendra mishr

Binding value isn't updating back to model?

$
0
0

I created a class derived from `DataGrid` so that I could override the templates used for column types when `DataGrid.AutoGenerateColumn` is set to `True`. Here is my DataGrid class:

public class DataGridEx : DataGrid
{
	protected override void OnAutoGeneratingColumn(DataGridAutoGeneratingColumnEventArgs e)
	{
		base.OnAutoGeneratingColumn(e);

		Type colDataType = e.PropertyType;

		if (colDataType == typeof(DateTime))
		{
			// Create a new template column.
			var templateColumn = new DataGridTemplateColumnEx();
			templateColumn.Header = e.Column.Header;
			templateColumn.CellTemplate = (DataTemplate)Resources["DateTimePickerCellTemplate"];
			templateColumn.CellEditingTemplate = (DataTemplate)Resources["DateTimePickerCellEditingTemplate"];
			templateColumn.SortMemberPath = e.Column.SortMemberPath;
			templateColumn.ColumnName = e.PropertyName;

			// Replace the auto-generated column with new template column
			e.Column = templateColumn;
		}
	}
}

However this caused the `DataContext` of the new `DataGridTemplateColumn` to be bound to the row item so I had to derive another class from `DataGridTemplateColumn` and override the `GenerateElement()` and `GenerateEditingElement()` functions to be able to bind the template contents back to the column's targeted property of the row item.

public class DataGridTemplateColumnEx : DataGridTemplateColumn
{
	public string ColumnName { get; set; }

	protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
	{
		// The DataGridTemplateColumn uses ContentPresenter with your DataTemplate.
		var cp = (ContentPresenter)base.GenerateElement(cell, dataItem);
		// Reset the Binding to the specific column. The default binding is to the DataRowView.
		BindingOperations.SetBinding(cp, ContentPresenter.ContentProperty, new Binding(this.ColumnName));
		return cp;
	}

	protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
	{
		// The DataGridTemplateColumn uses ContentPresenter with your DataTemplate.
		var cp = (ContentPresenter)base.GenerateEditingElement(cell, dataItem);
		// Reset the Binding to the specific column. The default binding is to the DataRowView.
		BindingOperations.SetBinding(cp, ContentPresenter.ContentProperty, new Binding(this.ColumnName));
		return cp;
	}
}

And here is the control as it appears in my view:

<c:DataGridEx AutoGenerateColumns="True" ItemsSource="{Binding}"><c:DataGridEx.Resources><DataTemplate x:Key="DateTimePickerCellTemplate"><TextBlock Text="{Binding}"/></DataTemplate><DataTemplate x:Key="DateTimePickerCellEditingTemplate"><!-- Needed to specify Path=. or else got error about two-way binding requiring a path or xpath. --><DatePicker Text="{Binding Path=., Mode=TwoWay}"/></DataTemplate></c:DataGridEx.Resources></c:DataGridEx>

This seems to work as far as the `TextBlock` is displaying the value of the property on the row item correctly. But with the `CellEditingTemplate` the `DatePicker` control appears when I try to edit the cell and has the correct initial value but when I change the date the changes are NOT being saved, the source value is NOT being updated.

Why isn't the source being updated here?



Shared variable to all my ViewModels/Services in WPF program

$
0
0

hello,

I've a property in MainViewModel that contains a parameter that must used in every class in my program. How can I have this parameter as global accessible to all ?

thanks

Black WPF Window when activating it from another application?

$
0
0

Hello,

i am developing a wpf app, but i have a problem when i activate my app from another application it shows totally black(demo on the bottom)

this code of activating my window work great but the window shows black

class WinApi2
{
    public const int SW_SHOWNORMAL = 5;

    [DllImportAttribute("user32.dll")]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImportAttribute("user32.dll")]
    public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

    [DllImportAttribute("user32.dll")]
    public static extern bool SetForegroundWindow(IntPtr hWnd);

    public static void ShowToFront(string windowName)
    {
        IntPtr firstInstance = FindWindow(null, windowName);
        ShowWindow(firstInstance, SW_SHOWNORMAL);
        SetForegroundWindow(firstInstance);
    }
}
// Activating my window by calling:
ShowToFront(".");

The result activated window but totally black:

demo problem

i found a solution by calling This.Show(); on the Activated Event of my wpf window 

 public  void Window_Activated(object sender, EventArgs e)
        {
            this.Show();
        }

but when doing that the black window still there it shows for a quick time and goes like flash that give a bad locking at the app showing. 

i tried the same code to show another app(created with c plus plus) no problem, but the problem is just with wpf apps i think Winforms too. who can i solver this problem ??

And Thank you.


WebBrowser zooming in WPF

$
0
0
I am using a System.Windows.Controls.WebBrowser control in my WPF application to display an HTML page, but require the ability to zoom in/out of the page.
I have found an option for windows forms: http://slingkid.blogsome.com/2007/04/13/ie-zoom/ , but I cannot see how/if this applies to the WPF WebBrowser control.

Any help would be appreciated

WPF, How to get button size created programmatically to a grid

$
0
0

I create a button proragmmatically to a grid and I want to get the size of the button.

But I use Width、ActualWidth、RenderSize attribute to get the size of the button failly.

I hope the button can grow by the text size of the Content.

Does someone know how to get a button size created programmatically to a grid?

Button button = new Button();
button.Click += button_Click;

button.HorizontalAlignment = HorizontalAlignment.Left;
button.VerticalAlignment = VerticalAlignment.Top;

button.Margin = new Thickness(tabIndex * 100, 0, 0, 0);
button.Content = onePageControl.Name;
button.Name = "button" + "_" + tabIndex.ToString();

this.contentGrid.Children.Add(button);



opening of web through wpf application

$
0
0
we are developing a project in PU pakistan.in one module we have to show data on web instead of wpf window on button click that placed on wpf window.we have two project in one solution one is wpf and second is web mvc4 project. we have to open web on button click.

Design time contextmenu Adding to the Menu in Visual Studio

$
0
0
I have problem in adding the menu item into menu in Visual Studio Design Time using Design Verbs using UserControl... If Any one knows pls reply me..

WPF Large Printing with header on all pages

$
0
0

I am developing  a one application and I want to print a record with header on all pages . It's possible in wpf? And i can also set page break according to content of record. And also have some image in record and i want  to fixing without cropping on next page means( if image does not fit in one page  then send to another page. If you have any demo then please provide.

I am  displaying record already in grid with scrolling.

Auto scroll canvas on button click

$
0
0

Hello,

In my application, i have a very big canvas which has many child elements in it. I want to add a kind of play and pause button which will allow user to scroll the content of a canvas horizontally. The feature should work if i click mouse wheel button also.

How i can do this for a Canvas control? Thanks in advance.

Thanks,

IamHuM

Viewing all 18858 articles
Browse latest View live


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