Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,583
|
Comments: 51,214
Privacy Policy · Terms
filter by tags archive
time to read 1 min | 100 words


I want to give a nice error message when windows integration is enabled. Now, WCF has this ability, and while it took me a while, I managed to track down the way they do it to this method:
HostedTransportConfigurationManager.MetabaseSettings.GetAuthenticationSchemes(base.HostedVirtualPath);
Which, of course, is internal.
Bad WCF, no cookie for you.
This is something really useful that I could make use of.
But, of course, Framework Design Guidelines says that you should make everything internal.
Argh!

The WPF mystery

time to read 1 min | 113 words

Okay, here are a few weird things that I wish I didn't know about WPF.

  • It does some low level cheating all over the place, for fun & profit, put the following like in the main window ctor:
    	Debug.Assert(Application.Current.MainWindow != this); 
    Remember that on the CLR, you don't often see other objects referencing before you even started your constructor.
  • Then there is this fun puzzle, when I am registering to the Application.Startup event, I am getting inconsistent results with regards to Application.MainWindow being null or not. After a short investigation, I pinned the blame on the async initialization of the windows. But it was a major PITA, to say the least.
time to read 14 min | 2674 words

I have made some progress since my last post, I now have removed the TextBlock hacks and am using buttons with replaced UI. The even look nice. I can't figure out how to get accelerator keys to work, I am pretty sure that I am doing everything right, but it doesn't work.

The button:

<Button

      Name="Next"

      Grid.Column="2"

      Click="Next_Click" >

      _Next &gt;&gt;

</Button>

The style (sans some UI stuff to make it shorter):

<Style TargetType="{x:Type Button}" >

      <Setter Property="Cursor"

                  Value="Hand"/>

      <Setter Property="Template">

            <Setter.Value>

                  <ControlTemplate>

                        <Border

                              Background="{StaticResource NormalBrush}"

                              BorderBrush="{StaticResource NormalBorderBrush}">

                              <TextBlock Style="{StaticResource BigText}"

                                             Name="TextField"

                                             Text="{TemplateBinding Property=Button.Content}">

                                    <ContentPresenter RecognizesAccessKey="True"/>

 

                              </TextBlock>

                        </Border>

                        <ControlTemplate.Triggers>

                              <Trigger

                                    Property="Button.IsPressed"

                                    Value="True">

                                    <Setter TargetName="Border"

                                                Property="Background"

                                                Value="{StaticResource PressedBrush}" />

                              </Trigger>

                        </ControlTemplate.Triggers>

                  </ControlTemplate>

            </Setter.Value>

      </Setter>

</Style>

The way it looks:

(Image from clipboard).png

Another issue that I am not sure how to solve is putting more controls on the navigation bar of the application:

(Image from clipboard).png

I am pretty sure that this involves overriding the style for NavigationWindow and doing something there, but I haven't been able to figure it out yet. The new stuff is in the repository if you feel like looking at it, of course.

time to read 4 min | 769 words

So here I am, only 3 days into WPF, and I have an interesting interview question. Given the following, what will be the title of the page? Why?

XAML:

<Page x:Class="Browser.BlogViewer"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="Foo">

</Page>

Code:

public partial class BlogViewer : Page

{

      public BlogViewer()

      {

            Title = “Bar”;

      }

}

 

time to read 4 min | 626 words

WPF / Ayende Viewer: Part III

The application is now composed of three screens, main one (choose categories):

(Image from clipboard).png

Select a post in a category:

(Image from clipboard).png

And view the posts in a category:

(Image from clipboard).png

Notice that you can page between the posts, this enables a very quick browsing experiance.

I commited the changes to the Rhino Tools repository (here), so you can see how I did it (not very complex). That data arrives from a sqlite database called ayende.blog using Active Record, of course.

Additional features that I want to add:

  • Add search capabilities, so I would be able to search the content / titles. Probably using SQLite full text searches. Allow to view the page results and to page through them.
  • Add tagging support, allow to browse the tags and page through tagged posts.

Not a lot of feature, eh?

Except that I have this list of things that I want to fix:

  • Give a uniform UI for the buttons in the first two screens, probaly on par with the prev/next links on the last screen.
  • Figure out control templates and replace the links on the last screen with a real control (right now it is a TextBlock with an event on MouseDown).
  • Figure out how to factor the common header into a seperate header control.
  • Add a column with the number of posts in each category.
  • Use WPF Commands instead of doing things in the events.
  • Figure out a better way to do paging than just moving between all those pages. There are advantages to this approach, so I think that I will keep them.
  • Put a meaningful title on the page, so the back button menu will look nice.
  • Put a Home button on the titlebar that will get you back to the main screen.
  • Figure out if an a really long chain of pages is a memory leak in the order that I should do something about. Yes, it is a memory leak, probably need to use KeepAlive=false, in which case the page will be discarded, and a new instance will be used when stepping back to it. As this is the default behavior, no need to do anything about it.
  • Figure out if triggers can replace the checks for next item, prev item. There isn't a way to do this properly, because there is an if pos+1 == count invovled.
time to read 12 min | 2259 words

(Image from clipboard).png

"Categories:" is static text, the rest is generated via this code:

IAddChild c = Categories;//Categories is a Stack Panel with Horizontal Orientation

foreach (Category category in post.Categories)

{

      TextBlock block = new TextBlock();

      block.Text = category.Name;

      block.Style = (Style) FindResource("BigText");

      c.AddChild(block);

      TextBlock seperator = new TextBlock();

      seperator.Text = "//";

      seperator.Style = (Style)FindResource("BigText");

      seperator.Foreground = Brushes.Brown;

      c.AddChild(seperator);

}

Is there a way to do this via XAML and not from the code?

I would like to thank Tomas Restrepo for pointing me in the direct direction, this is indeed possible, like this:

<ItemsControl Name="Categories"

                    ItemsSource="{Binding}">

      <ItemsControl.ItemsPanel>

            <ItemsPanelTemplate>

                  <WrapPanel Orientation="Horizontal"/>

            </ItemsPanelTemplate>

      </ItemsControl.ItemsPanel>

      <ItemsControl.ItemTemplate>

            <DataTemplate>

                  <WrapPanel>

                        <TextBlock Text="{Binding Path=Name}" Tag="{Binding Path=CategoryId}"

                                       MouseDown="Category_Browse"

                                       Style="{StaticResource BigText}"/>

                        <TextBlock Text="//"

                                       Foreground="Brown"

                                       Style="{StaticResource BigText}"/>

                  </WrapPanel>

            </DataTemplate>

      </ItemsControl.ItemTemplate>

</ItemsControl>

Notice the ItemsSource="{Binding}", which tripped me at first. Also, note that I am binding the tag of the text blog to the ID of the category. I don't really like this, but I couldn't figure out how to bind to the current item itself.

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. Production postmorterm (2):
    11 Jun 2025 - The rookie server's untimely promotion
  2. Webinar (7):
    05 Jun 2025 - Think inside the database
  3. Recording (16):
    29 May 2025 - RavenDB's Upcoming Optimizations Deep Dive
  4. RavenDB News (2):
    02 May 2025 - May 2025
  5. Production Postmortem (52):
    07 Apr 2025 - The race condition in the interlock
View all series

Syndication

Main feed ... ...
Comments feed   ... ...
}