|
Rough and dirty!!!
<Window x:Class="AddTabItem.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<TabControl x:Name="TabControl1"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Grid.Column="0" Grid.Row="0" Grid.RowSpan="1" />
<Button x:Name="btnAddTab" Content="Add Tab" Click="btnAddTab_Click"
Grid.Row="1" Grid.RowSpan="1"/>
</Grid>
</Window>
namespace AddTabItem
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void btnAddTab_Click(object sender, RoutedEventArgs e)
{
AddTabs();
}
private void AddTabs()
{
TabItem tabitem = new TabItem();
Button button = new Button();
button.Content = "Added Button!";
tabitem.Content = button;
TabControl1.Items.Add(tabitem);
TabControl1.SelectedIndex = TabControl1.Items.Count;
}
}
}
|
|
|
|
|
Thanks for the helpful responses. It works very well however, how am I able to define a specific User Control that I want to be added as the new tab item in the tab control based on click of the button.
Also I would like to ask what would be the best way of doing this and the terminologies, resources (I will do the coding myself)
I have a program which utilizes the Tab Control as the main user interface. It also has a toolbar with many tools, when clicked on a tool from the toolbar, the tool's user interface options will be placed in the Tab Control area, the name of the Tool will be like a Tab Header, any events, extra options in the Tool will be displayed as extra Tab Items in the Tab header. Since the toolbar will have many tools and if clicked on, they will do the same but not overwrite the current launched tool interface but create a separate Tab Header, and Tab Items if necessary. I hope I explained it correctly, if not I will be more than happy to create a Picture for better understanding. Basically the program is a big Tab Control, its tool options/anything else are smaller Tab Controls. Thanks for any suggestions or help.
|
|
|
|
|
|
Can you also share the comparison between your tool and agTweener or other SL Animation Library?
|
|
|
|
|
Mole is a debugger visualer. Silverlight does not support debugger visualizers. This is on SL product that does some of what Mole does in SL. I just don't remember the name.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
ListView doesnt support keyboard navigation.Is there any solution for this?
|
|
|
|
|
Well - I'm not sure how you've created your ListView, but this one does:
<Window x:Class="KeyViewListView.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<StackPanel>
<ListView x:Name="MyList" HorizontalAlignment="Left" >
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" Width="200" />
<TextBlock Text="{Binding Path=Age}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Window>
|
|
|
|
|
|
I have a WPF application in which I need to programmatically set the background and isTapStop properties of every textbox and listbox displayed based on pre-defined data that will be retrieved from a database and loaded into a List<t> when the app loads.
To be short in my description, there are 3-4 display types that my app uses. Based on the selected display type (just a value in a combox box) I will need to dynamically set the background and isTabStop value of these controls. My first hunch is to implement a class that iterates the DependencyObjects retured by the VisualTreeHelper, then check to see whether or not the element is a textbox or listbox, then check the control's binding path.path to see what database field it's bound to. That will work, as once I retrieve this I can set these two properties in code.
My question is this: is there a better way to do it?
|
|
|
|
|
Have you considered using TRIGGERS in a STYLE applied to the controls.
Then you don't have to write any code.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi, I'm developing a WPF application that seems to work fine, but after an long inactivity period, when the user clicks something it freezes for a while then it runs normally. This is the only application running in that computer, so I don't know what could be causing this.
In my application I need to check the time between user clicks so I'm intercepting Windows messages like this:
void Window_Loaded(object sender, RoutedEventArgs e)<br />
{<br />
ResetTimeoutChecker();
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);<br />
source.AddHook(new HwndSourceHook(myWndProc));<br />
}<br />
<br />
private static IntPtr myWndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)<br />
{<br />
if (msg == 0x0201)
ResetTimeoutChecker();<br />
<br />
return IntPtr.Zero;<br />
}
|
|
|
|
|
Maybe you can use one of the WPF Preview... events on your Window. Since the Window will "see" the event before it happens, you can perform you checks there. Then you can remove all the above code.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
thanks man, I'm gonna try that right now, but I don't think its gonna make a difference
|
|
|
|
|
Hey All,
I was just thinking about this question since it was/is a fairly large topic of discussion on the web this year. Isn't Blend itself a good example of the fact that it is ready ...
Just a thought ...
|
|
|
|
|
It certainly is ready for LOB apps, and if you want to take a look at the work that Karl is doing, you'll see more examples of WPF and LOB apps. BTW - Visual Studio (future versions) will be more WPF based, with more of the interface being developed in WPF.
|
|
|
|
|
Agreed.
I'm really looking forward to what Karl contributes to the whole thing. VS is a great IDE and more WPF integration can only be a good thing imho.
|
|
|
|
|
Also worth mentioning is the fact that Expression Blend is entirely written in WPF.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
I'm pretty sure that was Jammer's point.
|
|
|
|
|
Yep...you're right. That's what happens when one doesn't fully read the original post.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
|
WPF is LOB ready today and this space will only get way better in the future.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
For sure ... i'm working on two LOB WPF apps at the moment.
|
|
|
|
|
Hi,
I am working with designing custom controls for WPF applications. My problem is I couldn't find a way to force a control property appear in the XAML window by default. It appears only when its changed by the user. for example a button has a propert called myProp which I initializes in the constructor, but It doesn't gets reflected in the XAML file of the window. pls tell me how to force a property to appear in the .xaml file, by default whenever a control is placed on the WPF window.
thanks in advance,
vinod
|
|
|
|
|
Simple answer, you can't. Sorry about that.
|
|
|
|
|
thn how microsoft manages to embed some control property into the xaml by default. Like the name proprty of a control derived from Usercontrol.
or can tell me if there is any work around
modified on Tuesday, October 14, 2008 2:50 AM
|
|
|
|