|
How about combining the two approaches? Since you've already managed to get the viewmodel into a static resource, something like this should work:
<DataGridComboBoxColumn
SelectedItemBinding="{Binding ExpenseCategory}"
ItemsSource="{Binding ExpTypes, Source={StaticResource vm}}"
Header="Category"
/>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for the reply. I've been crawling my way towards that solution by incrementally melding some of the elements of Julie Lerman's approach with a DataGridComboBoxColumn, just hadn't gotten all the way to the one you've suggested. However, I've just tried your code and it works. Much more concise.
Probably should have mentioned in the original question that I'd taken the [non-working] syntax directly from MSDN's latest example for combo box columns, and that had me flummoxed.
|
|
|
|
|
Bonjour,
I'm using Avalondock in my project.
I'm trying to restore a layout saved in a xml file.
All is right.
But hidden Anchorable layout are not showed even if they are defined in a visible layout.
Could you help me ?
Thanks a lot.
|
|
|
|
|
Hello everyone.
I need to have a RichTextBox like input control to use in an application like MS Word. But the challenge is to input text diagonally. Currently I used a RichTextBox and a TextEffect for Runs in Document property of the RichTextBox to show text diagonally and it works. Unfortunately the cursor appears in its original position and direction so the user will be confused what he edit and where he type. Can you help me?
|
|
|
|
|
TextEffect just affects the text. If you apply a RotateTransform to the control, you'll rotate the entire control (including the caret).
|
|
|
|
|
Thank you SledgeHammer01. That's right, but I want to have diagonal lines not diagonal textbox.
|
|
|
|
|
You said you wanted a diagonal textbox. Diagonal input & Diagonal caret???
|
|
|
|
|
I need a portrait style RichTextBox but with diagonal lines (input and display)
|
|
|
|
|
Then you need to put the RichTextBox inside of another border and remove the border from the RichTextBox itself. Then apply the RotateTransform to just the inner RichTextBox. Will give the illusion of a horizontal RichTextBox with diagonal text.
You might also be able to modify the control template of the RichTextControl itself so you don't need the 2nd border.
|
|
|
|
|
I am using this[^] theme.
In the XAML when I use mouse to select some text everything highlights fine. But when I click an element in the design I do not see it highlighted in the XAML. I've searched this in the options but I can't find it.
Anyone know how to change this?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Hello,
how to make ScrollViewer with non scrollable band on left, or how to make partially non scrollable control?
Thank you.
|
|
|
|
|
I am struggling with the syntax to get the TextTemplate from a static resource.
<Selectors:RuleAttrSelector.TextTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="500" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource GridCellRight}"
Text="{Binding Path=Label}"
VerticalAlignment="Center" />
<TextBox Grid.Column="1"
Text="{Binding DisplayValue}"
Style="{StaticResource ReadOnlyTextBox}" />
</Grid>
</DataTemplate>
</Selectors:RuleAttrSelector.TextTemplate>
I need this template selector to be reused in multiple forms but cannot work out the correct syntax.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello,
I ListView Control I filled in a Click bouton.Et what I want is to control the lines of the ListView rows that contain the same elements as in the image below.
here is the link for the image.
http://social.msdn.microsoft.com/Forums/getfile/417417.
this is "Inventory Management" genre ie if a product exists, it increases the amount, if we insert the new quantity but not in a database, but rather in a ListView
I already do this last code to check if there are double lines but it does not work
AddArticleCollection.Add(new ArticleModel {
ID = txtIDProduit.Text,
Design = txtDesigProduit.Text,
Qte = int.Parse(txt_qte_produit.Text),
PrixVente = double.Parse(txtPUProduit.Text)
});
foreach (var item in AddArticleCollection)
{
if (ListVarticle_pr_vend.Items.Contains(item))
{
InfoBox info = new InfoBox("trouvé");
info.ShowDialog();
}
else
{
ListVarticle_pr_vend.Items.Add(item);
}
}
I thank you in advance and sorry for my english twisted.
|
|
|
|
|
Everything is wonderful. Then all of a sudden, it starts throwing exceptions...in the Designer.
The app itself compiles fine, runs fine, I just can't see any of the user controls because of index out of range and the like.
Duh. How can I have an SelectionChanged event coded if it keeps objecting to me using the SelectedIndex property in it?
Yeah, yeah, I know.
But why has it worked fine for months and now it doesn't? Some magic setting somewhere I accidentally set or unset?
VS2012, C#
|
|
|
|
|
I usually find this is an issue for two reasons:
- A (dependency) property on a control is not being set in the default or specified style. This usually happens most on custom controls or controls where I have overridden the default template. Specifying a default value for a property in the default style will usually make this one go away.
- A custom control (or extended control) doesn't handle the binding to a null object correctly. If, for example, you have something bound to a property on a view model but that property is a nullable type, in design mode it will probably be null. When the design surface mocks the VM to present a design-time view, the property evals to null and can throw an exception if the control doesn't handle it properly. If it is a control you wrote/overrode, you can fix it by handling a null value bound to the offending DP. Otherwise, add design-time code to provide a valid value for the offending VM property. (If you are using a framework like MVVMLight, IsInDesignMode is part of the VM base class. Otherwise, System.ComponentModel.DesignerProperties.GetIsInDesignMode will tell you.
Beyond this, good luck. Xaml designer exceptions are especially painful to try to decode. It won't make you feel any better but I've even had the design surface crash repeatedly but clear up after a reboot.
|
|
|
|
|
Yeah. If I do a Clean and then a Rebuild, it displays nicely...for a few minutes, then goes back to not being able to display the controls.
It's just annoying. Of course, any changes I make to the user controls are done on themselves, not on their parent, so it's not a problem as such. Just grrrr. :p
I just can't figure what I could possibly have done to make it stop working after it has been working for so long.
|
|
|
|
|
It usually gives you a pretty damn good hint as to what's wrong. Either in the error dialog or red / blue squiggles. It's entirely possible to have your XAML squiggled without seeing the error dialog. Some people like to ignore those squiggles, but 11 times out of 10, they indicate a real problem.
If you aren't getting an error dialog or squiggles, you can add a global exception handler to your app and pop up a message box, do a full re-build and restart Visual Studio. When it loads your XAML and gets the exception, it'll pop up the message box.
You are probably accessing something that isn't available / initialized yet at design time.
|
|
|
|
|
Yep.
No squiggles, though. And the Stack Traces and Inner Exceptions pointed to all sorts of bizarre places having nothing to do with the actual problem:
App.Current.Windows[0]
App is apparently not available at designtime.
So I wrapped the place it was being used in
<a href="http://www.youtube.com/GenJerDan">YouTube</a>
and
My <a href="http://www.persongo.net/">Mu[sic], Films and Windows Programs, etc.</a>
|
|
|
|
|
I am creating an app that will replace the Linq-To-SQL designer. Most of the code you see is from other apps I found on CP or other places all pieced together.
My app is here[^]. So far there's not much there.
If you run it you will see a mock table on the designer surface. It can be moved around. There is Select checkbox in the upper left corner of the main window. Checking it turns on the table's adorners for sizing.
Problem:
What I want to do is turn on the sizing adorners on the table when the table's header or footer area is clicked. But because both the header & footer border controls have their IsHitTestVisible set to False, the MouseDown even doesn't fire.
I'm not really sure how to make this work. I could use some help.
Many thanks!
If it's not broken, fix it until it is
|
|
|
|
|
I'm not sure the hit test is the problem. I didn't dive in really deep but when you move your mouse over the table, the cursor switches to the cross to indicate moving the table. However, you have to click to move the table. I'm guessing that clicking on the header of the table is actually activating the table move logic... meaning the "move" action is swallowing the click on the header you want.
I suggest moving that table move functionality down. If you want to click on the header and show the size adorners then move the cross/table move functionality down in the visual tree. Or switch to a double-click to show the size adorners. (That would seem more "normal" to me anyway)
HTH!
|
|
|
|
|
I understand that when you drag a table onto the designer surface the designer will add relation lines to other tables in the designer if there are corresponding FK's.
If you remove a relation will the underlying DB will still enforce FK violations?
If so, so what purpose do the relations serve in the designer?
Thanks
If it's not broken, fix it until it is
modified 10-Feb-14 13:38pm.
|
|
|
|
|
I have a boolean value to which radio buttons are bound, like so:
<RadioButton x:Name="Aye"
GroupName="wah"
IsChecked="{Binding IsChecked}">
<TextBlock>Yes</TextBlock>
</RadioButton>
<RadioButton x:Name="Nae"
GroupName="wah"
IsChecked="{Binding IsChecked,
Converter={StaticResource boolInv}}">
<TextBlock>No</TextBlock>
</RadioButton>
In VM property looks like this:
private bool isChecked;
public bool IsChecked
{
get { return isChecked; }
set
{
if (isChecked!= value)
{
isChecked = value;
OnPropertyChanged("IsChecked");
}
}
}
If the bound value is true, when I first open the screen the Yes checkbox is checked. I can select yes or no and they will display and save correctly. However, if I open the screen with a no value, nothing is checked. I believe the problem lies in the fact that when IsChecked is false, the converter converts that value to true in order to display the No box as checked, but in doing so it sets the IsChecked property to true, which then means that the No button should not be checked. The converter is the standard bool inverter all over the internet.
I didnae write this code, just trying to debug it.
Cheers, --EA
|
|
|
|
|
Have you tried setting Mode=OneWay on the "Nae" binding?
<RadioButton x:Name="Nae"
GroupName="wah"
IsChecked="{Binding IsChecked, Converter={StaticResource boolInv}, Mode=OneWay}">
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
have a Listbox in which I have added two controls i.e a Checkbox and a Datagrid side by side as a Listboxitem. I have done it in a following manner:
In Code behind: listBox1.items.Add(dt)
here dt is the table name.
In Xaml:
<ListBox Grid.Row="0" AlternationCount="2" MinHeight="305" HorizontalAlignment="Stretch" Name="listBox1" VerticalAlignment="Stretch" MinWidth="537" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Name="stkPanel" MinHeight="80" MinWidth="500" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<DataGrid Grid.Column="1"
AutoGenerateColumns="True"
MinHeight="75"
HorizontalAlignment="Center"
Name="dataGrid1"
VerticalAlignment="Stretch"
MinWidth="470"
MaxWidth="900"
ItemsSource="{Binding}"
IsReadOnly="True" Background="#E6BAB7B7">
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<CheckBox Name="colCheckBox" IsChecked="{Binding IsChecked, ElementName=IsDone, Mode=OneWay}" Content="{Binding}"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.ColumnHeaderStyle>
</DataGrid>
<CheckBox Grid.Column="0" Height="35" Width="25" Name="IsDone" HorizontalAlignment="Right" VerticalAlignment="Center" Checked="IsDone_Checked" />
</Grid>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Suppose for first listboxitem, there is "IsDone" checkbox and a datagrid. If I select "IsDone" check box (listbox item) all the datagrid column header check box is selected.Now, I can uncheck some of the datagrid coulmn header check boxes.What I want is to get values of the entire column only whose columnheader check box is checked and bind those values to a datatable.Similarly repeat the above process for other listbox item.Can you please suggest me how to do that in wpf?
modified 6-Feb-14 0:39am.
|
|
|
|
|
I'm creating an HwndHost subclass in C++/CLI to render DirectX contents.
I got it working but...
When I debug and select win32 and native check I often get this exception when I exit my sample app:
First-chance exception at 0x75212EEC (KernelBase.dll) in WRLDesktop.exe: 0x0000071A: The remote procedure call was canceled, or if a call time-out was specified, the call timed out.
If there is a handler for this exception, the program may be safely continued.
When I look at the (external) call stack I get that:
wtsapi32.dll!56eb210f() Unknown
WindowsBase.ni.dll!5cf134c8() Unknown
[Managed to Native Transition]
PresentationCore.dll!System.Windows.Interop.HwndTarget.Dispose() Unknown
PresentationCore.dll!System.Windows.Interop.HwndSource.Dispose(bool disposing) Unknown
PresentationCore.dll!System.Windows.Interop.HwndSource.OnHwndDisposed(object sender, System.EventArgs args) Unknown
WindowsBase.dll!MS.Win32.HwndWrapper.Dispose(bool disposing, bool isHwndBeingDestroyed) Unknown
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Unknown
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Unknown
[Native to Managed Transition]
user32.dll!74cf7694() Unknown
user32.dll!74cf95ab() Unknown
So, it seems there is an HwndTarget that is deleted when it shouldn't, or deleted twice, I dunno...
What could be wrong?
My implementation is like the few sample on the web, along those lines:
public ref class D2DHost : public HwndHost
{
private:
HWND mWnd;
public:
D2DHost() {}
protected:
virtual HandleRef BuildWindowCore(HandleRef hwndParent) override
{
HWND parentHwnd = (HWND)hwndParent.Handle.ToPointer();
mWnd = ::CreateWindowEx(0, "static", NULL,
WS_CHILD | WS_VISIBLE,
0, 0, 100, 100,
parentHwnd,
NULL,
(HINSTANCE)GetModuleHandle(NULL),
NULL);
if (!mWnd)
return HandleRef(nullptr, System::IntPtr::Zero);
return HandleRef(this, IntPtr(mWnd));
}
virtual void DestroyWindowCore(HandleRef hwnd) override
{
::DestroyWindow(mWnd);
}
};
|
|
|
|
|