Search Results

Search found 5961 results on 239 pages for 'wpf 4 5'.

Page 82/239 | < Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >

  • wpf working state

    - by taras.roshko
    Hi, I have a grid in my application. After user selects some files in ofdialog application processes some calculations. While app is making calculations it looks like it is not responding. How to display some picture and make main window in black&white while calculating? Maybe make some dp in MainWindow a la "IsBusy" and bind a popup with picture to it? How you implement this logic in yours apps?

    Read the article

  • create board for game with events support in WPF

    - by netmajor
    How can I create board for simple game, looks like for chess,but user could dynamically change number of column and rows? In cells I could insert symbol of pawn, like small image or just ellipse or rectangle with fill. This board should have possibility add and remove pawn from cells and move pown from one cell to another. My first idea was Grid. I do it in code behind, but it's hurt to implement events or everything in runtime create board :/ int size = 12; Grid board = new Grid(); board.ShowGridLines = true; for (int i = 0; i < size;i++ ) { board.ColumnDefinitions.Add(new ColumnDefinition()); board.RowDefinitions.Add(new RowDefinition()); } //komputer Rectangle ai = new Rectangle(); ai.Height = 20; ai.Width = 20; ai.AllowDrop = true; ai.Fill = Brushes.Orange; Grid.SetRow(ai, 0); Grid.SetColumn(ai,0); //czlowiek Rectangle hum = new Rectangle(); hum.Height = 20; hum.Width = 20; hum.AllowDrop = true; hum.Fill = Brushes.Green; Grid.SetRow(hum,size); Grid.SetColumn(hum,size); board.Children.Add(ai); board.Children.Add(hum); this.Content = board; It's a way to do this dynamically col and row change in XAML ? It's better way to implement that board create and implement events on move pawn from one cell to another ?

    Read the article

  • WPF - Get combobox checked property from ListBox

    - by Chris Klepeis
    I have a listbox, which is defined like so: <ListBox ItemsSource="{Binding Source={x:Static local:ResourceCollection.resourceList}}" Height="143" HorizontalAlignment="Left" Margin="6,6,0,0" Name="assignmentLB" VerticalAlignment="Top" Width="287" FontSize="12" FontWeight="Normal" IsEnabled="True" Grid.Column="0"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <CheckBox /> <TextBlock Text="{Binding Content}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> How can I loop through this listbox and retrieve the TextBlock.Text value for only items whose Checkbox has been checked?

    Read the article

  • Forcing Arrange in a Custom WPF Canvas

    - by Alex Marshall
    Hello, I'm working on a project that involves creating a custom graphical editor. The graphical editor has multiple tabs, and I want to create a preview function that will show a popup with Bitmap previews of the content of each of the tabs. However, the problem I'm running into is that the content for each of the tabs must be arranged before a proper preview can be generated for it. This means going into each of the tabs to ensure that they're rendered and arranged. Then, and only then, do the previews get properly generated, otherwise the previews have a size of 0x0. Does anybody know how to force an arrange of a content control so that I can get a properly sized preview generated ?

    Read the article

  • backgroundworker+wpf -> frozen window

    - by Valetudox
    -progressbar always 0% -the window is froozen (while DoWork r.) -if System.threading.thread.sleep(1) on - works perfectly whats the problem? private void btnNext_Click(object sender, RoutedEventArgs e) { this._worker = new BackgroundWorker(); this._worker.DoWork += delegate(object s, DoWorkEventArgs args) { long current = 1; long max = generalMaxSzam(); for (int i = 1; i <= 30; i++) { for (int j = i+1; j <= 30; j++) { for (int c = j+1; c <= 30; c++) { for (int h = c+1; h <= 30; h++) { for (int d = h+1; d <= 30; d++) { int percent = Convert.ToInt32(((decimal)current / (decimal)max) * 100); this._worker.ReportProgress(percent); current++; //System.Threading.Thread.Sleep(1); - it works well } } } } } }; this._worker.WorkerReportsProgress = true; this._worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { this.Close(); }; this._worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args) { this.statusPG.Value = args.ProgressPercentage; }; this._worker.RunWorkerAsync(); } <Window x:Class="SzerencsejatekProgram.Create" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Létrehozás" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="500" Width="700"> <DockPanel> <Button DockPanel.Dock="Right" Name="btnNext" Width="80" Click="btnNext_Click">Tovább</Button> <StatusBar DockPanel.Dock="Bottom"> <StatusBar.ItemsPanel> <ItemsPanelTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/> </Grid.ColumnDefinitions> </Grid> </ItemsPanelTemplate> </StatusBar.ItemsPanel> <StatusBarItem Grid.Column="1"> <TextBlock Name="statusText"></TextBlock> </StatusBarItem> <StatusBarItem Grid.Column="2"> <ProgressBar Name="statusPG" Width="80" Height="18" IsEnabled="False" /> </StatusBarItem> <StatusBarItem Grid.Column="3"> <Button Name="statusB" IsCancel="True" IsEnabled="False">Cancel</Button> </StatusBarItem> </StatusBar> </DockPanel> </Window>

    Read the article

  • Dynamic menu items in WPF

    - by mattdekrey
    Is there a way to create a section on a menu for a list of menu items to be populated by something like an ObservableCollection? I'd like to replicate the Window functionality in Visual Studio, where the open document tabs are listed in a numbered list, limited to the first 10.

    Read the article

  • navigate all items in a wpf tree view

    - by Brian Leahy
    I want to be able to traverse the visual ui tree looking for an element with an ID bound to the visual element's Tag property. I'm wondering how i do this. Controls don't have children to traverse. I started using LogicalTreeHelper.GetChildren, which seems to work as intended, up until i hit a TreeView control... then LogicalTreeHelper.GetChildren doesnt return any children. Note: the purpose is to find the visual UI element that corresponds to the data item. That is, given an ID of the item, Go find the UI element displaying it. Edit: I am apparently am not explaining this well enough. I am binding some data objects to a TreeView control and then wanting to select a specific item programaticly given that business object's ID. I dont see why it's so hard to travers the visual tree and find the element i want, as the data object's ID is in the Tag property of the appropriate visual element. I'm using Mole and I am able to find the UI element with the appropriate ID in it's Tag. I just cannot find the visual element in code. LogicalTreeHelper does not traverse any items in the tree. Neither does ItemContainerGenerator.ContainerFromItem retrieve anything for items in the tree view.

    Read the article

  • How to display Bitmap Image in image control on WPF using C#

    - by Sam
    I want that when I double click on a row in Listview, it should display the image corresponding to that row. This row also contains the path of the image. I tried the following but it displays the same image for all rows because I have given the path for a specific image: private void ListViewEmployeeDetails_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ImageSource imageSource = new BitmapImage(new Uri(@"C:\northwindimages\king.bmp")); image1.Source = imageSource; } Please suggest

    Read the article

  • WPF: How to properly override the methods when creating custom control

    - by EV
    Hi, I am creating a custom control Toolbox that is derived from ItemsControl. This toolbox is supposed to be filled with icons coming from the database. The definition looks like this: public class Toolbox : ItemsControl { protected override DependencyObject GetContainerForItemOverride() { return new ToolboxItem(); } protected override bool IsItemItsOwnContainerOverride(object item) { return (item is ToolboxItem); } } Toolboxitem is derived from ContentControl. public class ToolboxItem : ContentControl { static ToolboxItem() { FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(ToolboxItem), new FrameworkPropertyMetadata(typeof(ToolboxItem))); } } Since the number of icons stored in a database is not known I want to use the data template: <DataTemplate x:Key="ToolBoxTemplate"> <StackPanel> <Image Source="{Binding Path=url}" /> </StackPanel> </DataTemplate> Then I want the Toolbox to use the template. <Toolbox x:Name="NewLibrary" ItemsSource="{Binding}" ItemTemplate="ToolBoxtemplate"> </Toolbox> I'm using ADO.NET entity framework to connect to a database. The code behind: SystemicsAnalystDBEntities db = new SystemicsAnalystDBEntities(); private void Window_Loaded(object sender, RoutedEventArgs e) { NewLibrary.ItemsSource = from c in db.Components select c; } However, there is a problem. When the code is executed, it displays the object from the database (as the ItemSource property is set to the object from the database) and not the images. It does not use the template. When I use the static images source it works in the right way I found out that I need to override the PrepareContainerForItemOverride method.But I don't know how to add the template to it. Thanks a lot for any comments. Additional Information Here is the ControlTemplate for ToolboxItem: <ControlTemplate TargetType="{x:Type s:ToolboxItem}"> <Grid> <Rectangle Name="Border" StrokeThickness="1" StrokeDashArray="2" Fill="Transparent" SnapsToDevicePixels="true" /> <ContentPresenter Content="{TemplateBinding ContentControl.Content}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter TargetName="Border" Property="Stroke" Value="Gray" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate>

    Read the article

  • WPF Datagrid Column Width codebehind

    - by mikemuhl
    Hi, i would like to replace the following xaml code : <Custom:DataGridTextColumn Header=" " Width="*"/>in codebehind. This xaml code fills my header to the end with my style.. this is what i want to get |name | number | this area uses "mystyle" end of grid -| this is what i now get : |name | number | unstyled area! end of grid -| as u see, i would like to fill the unstyled area with my style, done this with xaml: now need in cb pls ;)

    Read the article

  • Group panel of WPF ListBox

    - by rulestein
    I have a listbox that is grouping the items with a GroupStyle. I would like add a control at the bottom of the stackpanel that holds all of the groups. This additional control needs to be part of the scrolling content so that the user would scroll to the bottom of the list to see the control. If I were using a listbox without the groups, this task would be easy by modifying the ListBox template. However, with the items grouped, the ListBox template seems to only apply on a per group basis. I can modify the GroupStyle.Panel, but that doesn't allow me to add items to that panel. <ListBox> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel/> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.GroupStyle> <GroupStyle> <GroupStyle.Panel> <ItemsPanelTemplate> <VirtualizingStackPanel/> **<----- I would like to add a control to this stackpanel** </ItemsPanelTemplate> </GroupStyle.Panel> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupItem}"> <Grid> <ItemsPresenter /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </GroupStyle.ContainerStyle> </GroupStyle> </ListBox.GroupStyle> This should give an idea of what I need to do:

    Read the article

  • WPF : Command routing for Keyboard shortcuts.

    - by Sprotty
    Basically I want to create a keyboard shortcut which is valid within the scope of a window, and not just enabled when focus is within the control that binds it. in more detail.... I have a window which has 3 controls a toolbar textbox Custom Control The toolbar has a button bound to the Command CustomCommands.CmdA and linked to 'Ctrl-T'. My Custom Control can process CmdA. When I run the app and click on my custom control CmdA is enabled and works fine. Also Ctrl-T cause the command to fire. However when I select the text box, my custom command CmdA becomes disabled. I can rectify this by setting the command target for CmdA's button. Now when I select the textBox, CmdA is still enabled. But the Keyboard shortcut Ctrl-T does nothing. Is there any easy way to change the scope of keyboard shortcuts? Or do I need to catch the keypress somewhere lower down, and work out which Command it relates to and route it myself (if so is there a framework within which to do this?) Many Thanks Simon

    Read the article

  • Unset/Change Binding in WPF

    - by captcalamares
    How can I unset the binding applied to an object so that I can apply another binding to it from a different location? Suppose I have two data templates binded to the same object reference. Data Template #1 is the default template to be loaded. I try to bind a button command to a Function1 from my DataContext class: <Button Content="Button 1" CommandParameter="{Binding }" Command="{Binding DataContext.Function1, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"/> This actually works and the function gets binded. However, when I try to load Data Template # 2 to the same object (while trying to bind another button command to a different function (Function2) from my DataContext class): <Button Content="Button 2" CommandParameter="{Binding }" Command="{Binding DataContext.Function2, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" /> It doesn't work and the first binding is still the one executed. Is there a workaround to this? EDIT (for better problem context): I defined my templates in my Window.Resources: <Window.Resources> <DataTemplate DataType="{x:Type local:ViewModel1}"> <local:View1 /> </DataTemplate> <DataTemplate DataType="{x:Type local:ViewModel2}"> <local:View2 /> </DataTemplate> </Window.Resources> The View1.xaml and the View2.xaml contain the button definitions that I described above (I want them to command the control of my process flow). ViewModel1 and ViewModel2 are my ViewModels that implement the interface IPageViewModel which is the type of my variable CurrentPageViewModel. In my XAML, I binded ContentControl to the variable CurrentPageViewModel: <ContentControl Content="{Binding CurrentPageViewModel}" HorizontalAlignment="Center"/> In my .CS, I have a list defined as List<IPageViewModel> PageViewModels, which I use to contain the instances of my two View Models: PageViewModels.Add(new ViewModel1()); PageViewModels.Add(new ViewModel2()); // Set starting page CurrentPageViewModel = PageViewModels[0]; When I try to change my CurrentPageViewModel to the other view model, this is when I want the new binding to work. Unfortunately, it doesn't. Am I doing things the right way?

    Read the article

  • WPF multibound textblock not updating

    - by Superstringcheese
    I want to create a program which calculates how long it will take to repeat a process a certain number of times. I've scaled this down a lot for this example. So, I have some textboxes which are bound to properties in a class: Count: <TextBox x:Name="txtCount" Text="{Binding Count, Mode=TwoWay}" Width="50"/> Days: <TextBox x:Name="txtDays" Text="{Binding Days, Mode=TwoWay}" Width="50"/> and a textblock which is multibound like so: <TextBlock x:Name="tbkTotal"> <TextBlock.Text> <MultiBinding StringFormat="Days: {0}, Count: {1}"> <Binding Path="Days" /> /* This isn't updating */ <Binding Path="Count" /> </MultiBinding> </TextBlock.Text> </TextBlock> My DataContext is set in the Window1.xaml.cs file. public Window1() { InitializeComponent(); Sample sample = new Sample(); this.DataContext = sample; } I can update the multibound textblock with the Count property just fine, but the Days property always shows 0, even though the Days input accurately reflects changes. I believe that this is because my accessors are different for Days - namely, the Set method. This class is in a different file. public class Sample : INotifyPropertyChanged { private int _count; private TimeSpan _span; public int Count { get { return _count; } set { _count = value; NotifyPropertyChanged("Count"); /* Doesn't seem to be needed, actually */ } } public TimeSpan Span { get { return _span; } } /* The idea is to provide a property for Days, Hours, Minutes, etc. as conveniences to the inputter */ public double Days { get { return _span.Days; } set { TimeSpan ts = new TimeSpan(); double val = value > 0 ? value : 0; ts = TimeSpan.FromDays(val); _span.Add(ts); NotifyPropertyChanged("Span"); /* Here I can only get it to work if I notify that Span has changed - doesn't seem to be aware that the value behind Days has changed. */ } } private void NotifyPropertyChanged(string property) { if (null != this.PropertyChanged) { PropertyChanged(this, new PropertyChangedEventArgs(property)); } } public Sample() { _count = 0; _span = new TimeSpan(); } public event PropertyChangedEventHandler PropertyChanged; }

    Read the article

  • WPF TextBox Focus

    - by Jezz
    I am setting focus on a Textbox like this: <DockPanel Margin="0,0,0,0" LastChildFill="True" FocusManager.FocusedElement="{Binding ElementName=messengerTextToSend}"> <ListBox x:Name="messengerLabelParticipants" DockPanel.Dock="Top" Height="79" Margin="0,1,0,0" Padding="0" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0" AllowDrop="True" ItemsSource="{Binding Path=involvedUsers}" ItemTemplate="{StaticResource chatParticipants}" Tag="{Binding Path=chatSessionID}" Drop="participantList_Drop" DragEnter="participantList_DragEnter" DragLeave="messengerLabelParticipants_DragLeave"> </ListBox> <TextBox x:Name="messengerTextToSend" Focusable="True" Margin="10,0,10,10" DockPanel.Dock="Bottom" Height="100" Tag="{Binding Path=.}" KeyUp="messengerTextToSend_KeyUp" Cursor="IBeam" Style="{StaticResource messengerTextBoxSendText}"/> <ScrollViewer x:Name="messengerScroller" Template="{DynamicResource ScrollViewerControlTemplate1}" ScrollChanged="messengerScroller_ScrollChanged" Loaded="messengerScroller_Loaded" Margin="0,10,0,10"> <ListBox x:Name="messengerListMessages" Margin="10,0,0,0" Padding="0" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=messages}" ItemTemplateSelector="{StaticResource messageTemplateSelector}"> </ListBox> </ScrollViewer> </DockPanel> However, when the page load, although the Textbox visually appears to have focus, the cursor is static and I have to manually either click on the Textbox or tab to it in order to start typing. I'm not sure what I'm doing wrong but I've tried every setting, inclduing setting it in the code to get it working. Any assistance would be greatly appreciated.

    Read the article

  • WPF style problem with custom control and textbox-derived class

    - by Martin
    I had the following situation: main application has app.xaml, which sets the style for TextBox controls a custom control is implemented in a separate DLL, and uses several TextBox controls The main application's TextBox style is applied to the custom control's TextBox controls. Cool! My problem comes in because I need to use a class derived from TextBox in the custom control. Now the main app's TextBox style is no longer applied. Can the custom control DLL have something like "app.xaml" where I can set the style for all my derived TextBox controls? Or can the main application somehow set the style for all TextBox-derived classes? Thanks!

    Read the article

  • WPF texbox focus when render to offscreen buffer

    - by dr.mo
    i am rendering a textbox to an offscreen buffer using RenderTargetBitmap and i want to enter text into this textbox, however, i can't set the textbox focus (using Focus() has no effect - presumably because the canvas is not attached to a real window?) this has two consequenes: 1 the keyboard input doesn't get captured 2. even if i set the text manually using TextBox text and CaretIndex = index i dont get a caret because of the lack of focus. is there a way to make this focus somehow? and if not, i'd like to at least have the caret visible even if there is no focus, but can't see a way of doing this.

    Read the article

  • WPF: How to refresh a window while debugging?

    - by Qwertie
    I am debugging an algorithm that is being represented by a set of ViewModels. In order to debug this algorithm I would like to redraw the View while stepping through part of the algorithm. Is this possible? (I would prefer to just repaint, not do what they call "DoEvents" to process all events.)

    Read the article

  • WPF: ComboBox SelectedIndex = -1 ??

    - by msfanboy
    Hello, I am using a MVVM Wizard with several pages. When I set a value in the combobox and go to the next page and switch back I want to reset the value I set before. But all whats happening is that the combobox is empty at top and the index is -1 ? What do I wrong? <ComboBox ItemsSource="{Binding Path=LessonNumbers}" SelectedIndex="{Binding SelectedLessonNumber}" /> private ReadOnlyCollection<int> _lessonNumbers; public ReadOnlyCollection<int> LessonNumbers { get { if (_lessonNumbers == null) this.CreateLessonNumbers(); return _lessonNumbers; } } private void CreateLessonNumbers() { var list = new List<int>(); for (int i = 1; i < 24; i++) { list.Add(i); } _lessonNumbers = new ReadOnlyCollection<int>(list); } private int _selectedLessonNumber; public int SelectedLessonNumber { get { return _selectedLessonNumber; } set { if (_selectedLessonNumber == value) return; _selectedLessonNumber = value; this.OnPropertyChanged("SelectedLessonNumber"); } }

    Read the article

  • remove eventhandler from wpf scrollviewer

    - by rubentjeuh
    I've got this: <ScrollViewer x:Name="svBegin" CanContentScroll="True"> <Grid x:Name="gGegevensGrid" KeyDown="gGegevensGrid_KeyDown" ScrollViewer.VerticalScrollBarVisibility="Visible"></Grid> </ScrollViewer> As you can see I've got a KeyDown eventhandler on the grid. But when I press the downkey, the scrollviewer scrolls down. Even when I try this, it doesn't work: svBegin.KeyDown += new KeyEventHandler(svBegin_KeyDown); svBegin.KeyDown -= new KeyEventHandler(svBegin_KeyDown); Anybody who knows how to solve this problem?

    Read the article

  • WPF MVVM Cancel Edit

    - by terkri
    How can I implement cancelation of editing an object using MVVM. For example: I have a list of customers. I choose one customer an click the button "Edit", a dialog window(DataContext is binded to CustomerViewModel) opens and I start editing customer's fields. And then I decide to cancel editing, but the fields of the customer have been already changed, so how can I return a customer to its previous state in MVVM?

    Read the article

  • Bind a WPF combobox and get selecteditem to a richtextbox

    - by Peter
    Hi, I am using a dataset on the server, in this dataset I have a datatable that calls a stored procedure and returns column names from three tables. I call this stored procedure using a web service. I manage to show all the column names in my combobox but when I want to click a button and insert selected column name into a richtextbox I get System.Data.DataRowView in the textbox instead. My code: 'the combobox 'if I don't have this textblock all the values are shown vertical instead of the normal horizontal lines 'the stored procedure SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE (TABLE_NAME = 'Customer') OR (TABLE_NAME = 'Invoices') OR (TABLE_NAME = 'Orders') 'the button Private Sub btnAddColumnNames_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnAddColumnNames.Click ' Add column names to the richtextbox Dim tr As New TextRange(rtbText.Selection.Start, rtbText.Selection.End) tr.Text = cboColumnNames.SelectedItem.ToString() rtbText.Focus() End Sub Any suggestions on how to get the selected text in the combobox to the richtextbox? Any help is appreciated.

    Read the article

< Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >