I have a WPF application where I'm using dependency properties in codebehind which I want to set via XAML declarations.
e.g.
<l:SelectControl StateType="A" Text="Hello"/>
So in this example I have a UserControl called SelectControl, which has a property called StateType which manipulate some other properties in it's setter.
To help...
How do I recreate the following XAML databinding in code? I have most of it except for the DataTemplate definition.
Here is an example of the DataBinding in XAML
<GridViewColumn Width="140" Header="Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=Label}" />
...
Hi. Simple WPF/XAML question. In XAML, how do I reference the Self/this object in a given context? In a very basic app with a main window, one control, and a coded C# property of the window, I want to bind a property of the control to the hand coded property of the window.
In code, this is very easy - in the Window's constructor, I add...
Hi. In a WPF app, what XAML code do I need to do the same job as this line of c#:
this.DataContext = this;
? Thanks
...
Is there a reason why the text content of a WPF button is appearing with unwanted space above the text?
I have a button in a StackPanel. This button is a simple close button so I want it to appear as a square button with an "x" centred in it. I have set my padding to zero and set both the HorizontalContentAlign and VerticalContentAlig...
I want to instantiate objects in XAML, and reuse these instances. I think it should be simple but I'm stuck, I'm probably missing something obvious.
Say I want to add Cats to different Rooms (Room has an ObservableCollection containing objects of type Cat). In the UserControl.Resources I create ObjectDataProviders:
<ObjectDataProvider ...
I have a collection that I am displaying in a WPF Listview. I will have an edit button in each row and need to pass an ID to another control on the screen when that's clicked. I'm not going to be editing in place so I'm not using the Gridview.
How do I pass this ID to my other control?
Currently my XAML looks like this.
<ListView Na...
I have a ListBox with an ItemTemplate which renders a Grid with two columns. The first column is a TextBlock and the second is a ComboBox.
The idea is to present to the user a list of questions and a Combo from which the user can choose an answer. This works ok with this xaml:
<ListBox x:Name="QAListBox" ScrollViewer.VerticalS...
Okay this one's pretty straightforward. I'm creating a checkbox in my Page.xaml.cs file, and assigning it some params. I need to link to events for checked and unchecked. What is the syntax for this?
Also, my current code looks like this:
CheckBox cb = new CheckBox();
cb.IsChecked = true;
System.Windows.Thicknes...
For some reason I get an exception.
Can someone please explain to me why and how can fix this?
I am trying to read a DataTemplate. If there is a better option please tell.
Thanks.
using System;
using System.Windows;
using System.Windows.Data;
using System.IO;
using System.Xaml;
using System.Xml;
namespace TestApp
{
public partial c...
I have two Window (name: window1 \ window2) whether it is possible to insert them in another Window (window3). What would have once been seen window1 \ window2, buyout lie window3?
...
I only found a way to:
<TextBox Text="Text!"
IsReadOnly="True"
IsTabStop="False"
BorderThickness="0"
>
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Va...
I need a tool for rapid code generation from
<DockPanel DockPanel.Dock="Top"><TextBlock Text=" " /><TextBox Style="{StaticResource TextBoxIsReadOnly}" Text="{Binding title}" Foreground="Chocolate" DockPanel.Dock="Left"/></DockPanel>
in:
<DockPanel DockPanel.Dock="Top">
<TextBlock Text=": " />
<TextBox Style="{StaticResource ...
I have a text box that appears in a certain size and position in the Visual Studio Silverlight preview window. When I actually run the app, it appears to be much wider, and lower on the page. Why is this? (Sometimes I can fix the problem by deleting the control and making a new one like it, but it's frustrating.)
This is the XAML:
<Tex...
I am running into a layout issue which I am not sure how to solve. Here is how my xaml looks like,
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid x:Name="abc" Grid.Row="0" Grid.Column="0">
<Grid>
<Grid.ColumnDe...
I have a datagrid which is populated from a web service. I want to fill a form based on the selected item in the datagrid.
This is what I use to set the DataContext (Which is a grid)
private void PublisherSearchList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.PublisherItem.DataContext = (Publisher)Publis...
Let's say we have the below code:
<Window
x:Class="Consus.Client.UI.Sandbox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
x:Name="Ribbo...
I have a very common question. What is the best way to do localization in a WPF app.
Well, I searched in SO and Binged a lot too. But I could not find any pointers which is really simple and elegant.
Assume that I have to display in UI something like:
In English: Orgnanization - Beoing
In French: Organizzazione - Beoing
<St...
I develop desktop-based WPF-application, that uses SQL Server 2008 R2 Database and ADO.NET Entity Framework as connection tool between database and application.
In one of the windows there is need to show content of database's table and let user to perform some manipulations, such as add new record to database, edit selected record and ...
This question relates to this question.
I have a EF model like this.
Using Silverlight 4 I have an application showing questions to the user, defined through the QuestionSet. If a question has more than one answer alternative, a ComboBox is rendered. If only one alternative is given, a TextBox is rendered, in which the user can put fre...